extras: add PowerShell greeting port, Rust gm-switch and Windows installers

- powershell_greeting: PowerShell port of fish_greeting (fastfetch random logo, sixel/kitty-direct per terminal, logs, modes)

- win-gm-switch: Rust port of gm-switch.cpp (cross-platform mode file, --status, Start Menu shortcuts installer)

- install-windows.ps1 umbrella installer; README pointers
This commit is contained in:
2026-09-30 09:34:01 -05:00
parent 9b431eb982
commit d2f857d3ee
12 changed files with 976 additions and 3 deletions
+105
View File
@@ -0,0 +1,105 @@
# Build and install gm-switch:
# * cargo build --release (needs the Rust toolchain on PATH)
# * copies gm-switch.exe to %LOCALAPPDATA%\J621\bin
# * adds that folder to your user PATH (if missing)
# * creates Start Menu shortcuts for each mode under "J621 Greeting"
#
# Usage:
# .\install.ps1
# .\install.ps1 -Uninstall
[CmdletBinding()]
param(
[switch]$Uninstall
)
$ErrorActionPreference = 'Stop'
$here = $PSScriptRoot
if (-not $here) { $here = Split-Path -Parent $MyInvocation.MyCommand.Path }
$binDir = Join-Path $env:LOCALAPPDATA 'J621\bin'
$exe = Join-Path $binDir 'gm-switch.exe'
$startMenuDir = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs\J621 Greeting'
if ($Uninstall) {
if (Test-Path -LiteralPath $startMenuDir) {
Remove-Item -LiteralPath $startMenuDir -Recurse -Force
Write-Host "Removed $startMenuDir"
}
if (Test-Path -LiteralPath $exe) {
Remove-Item -LiteralPath $exe -Force
Write-Host "Removed $exe"
}
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if ($userPath) {
$parts = @($userPath -split ';' | Where-Object { $_ -and $_ -ne $binDir })
[Environment]::SetEnvironmentVariable('Path', ($parts -join ';'), 'User')
Write-Host "Removed $binDir from your user PATH"
}
exit 0
}
# --- Build ---------------------------------------------------------------------
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
Write-Host 'cargo was not found on PATH - install the Rust toolchain (https://rustup.rs) first.'
exit 1
}
Push-Location $here
try {
Write-Host 'Building gm-switch (cargo build --release) ...'
# cargo writes progress to stderr; keep that from tripping $ErrorActionPreference.
$previousPreference = $ErrorActionPreference
$ErrorActionPreference = 'Continue'
cargo build --release 2>&1 | Write-Host
$buildExit = $LASTEXITCODE
$ErrorActionPreference = $previousPreference
if ($buildExit -ne 0) {
Write-Host 'cargo build failed.'
exit 1
}
} finally {
Pop-Location
}
$built = Join-Path $here 'target\release\gm-switch.exe'
if (-not (Test-Path -LiteralPath $built)) {
Write-Host "Build output not found: $built"
exit 1
}
# --- Install -------------------------------------------------------------------
New-Item -ItemType Directory -Path $binDir -Force | Out-Null
Copy-Item -LiteralPath $built -Destination $exe -Force
Write-Host "Installed $exe"
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if (-not $userPath) { $userPath = '' }
if (-not (($userPath -split ';') -contains $binDir)) {
$newPath = ($userPath.TrimEnd(';') + ';' + $binDir).TrimStart(';')
[Environment]::SetEnvironmentVariable('Path', $newPath, 'User')
Write-Host "Added $binDir to your user PATH (open a new terminal to pick it up)"
}
# --- Shortcuts ------------------------------------------------------------------
New-Item -ItemType Directory -Path $startMenuDir -Force | Out-Null
$modes = @(
@{ Value = '0'; Name = 'NSFW' },
@{ Value = '1'; Name = 'SFW' },
@{ Value = '2'; Name = 'Questionable' }
)
$shell = New-Object -ComObject WScript.Shell
foreach ($m in $modes) {
$lnkPath = Join-Path $startMenuDir ('J621 Greeting - ' + $m.Name + '.lnk')
$shortcut = $shell.CreateShortcut($lnkPath)
$shortcut.TargetPath = "$env:SystemRoot\System32\cmd.exe"
$shortcut.Arguments = '/k ""' + $exe + '" --mode ' + $m.Value + '"'
$shortcut.WorkingDirectory = $env:USERPROFILE
$shortcut.Description = 'Set the J621 shell greeting to ' + $m.Name + ' mode'
$shortcut.Save()
Write-Host ('Created shortcut: ' + $lnkPath)
}
Write-Host ''
Write-Host 'Done. Try: gm-switch --status'
Write-Host 'The Start Menu shortcuts open a small console showing the confirmation.'
exit 0