Files
dikte/install.ps1
T
yusufipek 476265465f Write the Windows installer in the language the rest of it is written in
install.sh and install-mac.sh are in English, and README.tr.md is where Turkish
lives. install.ps1 arrived in Turkish, and in a Turkish with the diacritics
stripped out of it, which is neither one language nor the other.

Two things while it was open: the `dikte` command ran whichever `python` the
PATH answered with rather than the one checked a few lines above it, and a
machine with no WindowsApps directory got no command and no word about why.
2026-08-16 10:29:07 +03:00

80 lines
3.4 KiB
PowerShell

# Installs Dikte for this Windows user: a Start Menu entry, an optional
# autostart entry, and a `dikte` command that works from any terminal.
#
# powershell -ExecutionPolicy Bypass -File install.ps1 # install
# powershell -ExecutionPolicy Bypass -File install.ps1 -Autostart # + start at sign-in
# powershell -ExecutionPolicy Bypass -File install.ps1 -Uninstall # remove
param(
[switch]$Autostart,
[switch]$Uninstall
)
$ErrorActionPreference = "Stop"
$repo = $PSScriptRoot
$startMenu = [Environment]::GetFolderPath("Programs")
$startup = [Environment]::GetFolderPath("Startup")
$shortcut = Join-Path $startMenu "Dikte.lnk"
$autostartLink = Join-Path $startup "Dikte.lnk"
# WindowsApps is already on the user PATH, so a dikte.cmd left there runs from
# any terminal without a PATH edit and without an administrator.
$cmdShim = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\dikte.cmd"
if ($Uninstall) {
foreach ($path in @($shortcut, $autostartLink, $cmdShim)) {
if (Test-Path $path) { Remove-Item $path -Force; Write-Host "removed: $path" }
}
Write-Host "Dikte's shortcuts are gone. The repository and your settings are not."
exit 0
}
# --- what it needs ----------------------------------------------------------
$python = Get-Command python -ErrorAction SilentlyContinue
if (-not $python) {
Write-Error "No python found. Install it with: winget install Python.Python.3.12"
}
$version = & python -c "import sys; print('%d.%d' % sys.version_info[:2])"
if ([version]$version -lt [version]"3.11") {
Write-Error "Python 3.11 or newer is needed, and this one is $version."
}
& python -c "import PyQt6.QtWidgets" 2>$null
if ($LASTEXITCODE -ne 0) {
Write-Host "Installing PyQt6..."
& python -m pip install PyQt6
if ($LASTEXITCODE -ne 0) { Write-Error "PyQt6 would not install." }
}
if (-not (Get-Command ffmpeg -ErrorAction SilentlyContinue)) {
Write-Warning "No ffmpeg found. Recording needs it: winget install Gyan.FFmpeg"
}
# pythonw.exe runs the same program without a console window behind it.
$pythonw = Join-Path (Split-Path $python.Source) "pythonw.exe"
if (-not (Test-Path $pythonw)) { $pythonw = $python.Source }
# --- the Start Menu entry ---------------------------------------------------
$shell = New-Object -ComObject WScript.Shell
foreach ($path in @($shortcut) + $(if ($Autostart) { @($autostartLink) } else { @() })) {
$link = $shell.CreateShortcut($path)
$link.TargetPath = $pythonw
$link.Arguments = "`"$repo\dikte.py`" --gui"
$link.WorkingDirectory = $repo
$link.Description = "Dikte: dictation"
$link.Save()
Write-Host "shortcut: $path"
}
# --- the dikte command ------------------------------------------------------
# The interpreter by its full path rather than by name: the one checked above is
# the one the command line should run, whatever a later PATH change puts first.
$shimDir = Split-Path $cmdShim
if (Test-Path $shimDir) {
"@echo off`r`n`"$($python.Source)`" `"$repo\dikte.py`" %*" |
Out-File $cmdShim -Encoding ascii
Write-Host "command: dikte ($cmdShim)"
} else {
Write-Warning "No $shimDir on this machine, so there is no dikte command. Run it as: python `"$repo\dikte.py`""
}
Write-Host ""
Write-Host "Installed. Start it from the Start Menu as 'Dikte', or type 'dikte' in a terminal."
Write-Host "The Settings window opens on the first run: download a model there and pick the shortcut (Ctrl+Space by default)."