From 4889c5c35596a52ad6d595c2f2113116e6c9c299 Mon Sep 17 00:00:00 2001 From: JakeBreath Date: Wed, 30 Sep 2026 09:44:36 -0500 Subject: [PATCH] extras/powershell_greeting: fix WezTerm logo stretch (iterm + preserveAspectRatio) kitty-direct sends c= but no rows through ConPTY (the terminal guesses the height and stretches); the plain kitty type needs tty pixel queries that ConPTY drops. The iterm type with preserveAspectRatio=1 letterboxes any aspect ratio. --- extras/powershell_greeting/J621Greeting.ps1 | 14 ++++++++++++-- extras/powershell_greeting/README.md | 8 +++++--- extras/powershell_greeting/config.example.ps1 | 6 ++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/extras/powershell_greeting/J621Greeting.ps1 b/extras/powershell_greeting/J621Greeting.ps1 index 2bfbb13..4f5314d 100644 --- a/extras/powershell_greeting/J621Greeting.ps1 +++ b/extras/powershell_greeting/J621Greeting.ps1 @@ -23,6 +23,7 @@ # J621_LOGO_TYPE force a fastfetch logo type (sixel, kitty-direct, ...) # J621_ALWAYS_FETCH=1 fetch even in terminals without image support # J621_LOGO_WIDTH logo width in columns (default 35) +# J621_LOGO_HEIGHT iterm box height in rows (default 25) #Requires -Version 5.1 @@ -99,7 +100,7 @@ function Show-J621Greeting { $logoType = $env:J621_LOGO_TYPE if (-not $logoType) { if ($env:WT_SESSION) { $logoType = 'sixel' } - elseif ($env:WEZTERM_PANE) { $logoType = 'kitty-direct' } + elseif ($env:WEZTERM_PANE) { $logoType = 'iterm' } } $fetchImage = [bool]$logoType -or ($env:J621_ALWAYS_FETCH -eq '1') $ffArgs = @(Get-J621FastfetchArgs) @@ -169,7 +170,16 @@ function Show-J621Greeting { # --- Display result --- if ($logoType) { - & fastfetch @ffArgs --logo-type $logoType --logo $tempFile --logo-width $logoWidth + $logoArgs = @('--logo-type', $logoType, '--logo', $tempFile, '--logo-width', $logoWidth) + if ($logoType -eq 'iterm') { + # Box + preserveAspectRatio: never stretched, whatever the aspect ratio + # (kitty-direct cannot do this through ConPTY: its payload has no rows). + $logoHeight = if ($env:J621_LOGO_HEIGHT) { $env:J621_LOGO_HEIGHT } else { '25' } + $logoArgs += @('--logo-height', $logoHeight, '--logo-preserve-aspect-ratio', 'true') + } elseif ($env:J621_LOGO_HEIGHT) { + $logoArgs += @('--logo-height', $env:J621_LOGO_HEIGHT) + } + & fastfetch @ffArgs @logoArgs } else { & fastfetch @ffArgs } diff --git a/extras/powershell_greeting/README.md b/extras/powershell_greeting/README.md index 2e24c61..81ac0e9 100644 --- a/extras/powershell_greeting/README.md +++ b/extras/powershell_greeting/README.md @@ -16,7 +16,7 @@ terminals. | JSON parsing | `jq` / `python3` / grep | `ConvertFrom-Json` (built-in) | | MIME detection | `file --mime-type` | PNG/JPEG/GIF magic bytes | | GIFs | `gifsicle` + `kitten icat` | none: static first frame in Windows Terminal, animated in WezTerm (its `kitty-direct` plays the GIF) | -| fastfetch logo | `--logo-type kitty --logo ... --logo-width 35` | `sixel` in Windows Terminal, `kitty-direct` in WezTerm, no image elsewhere | +| fastfetch logo | `--logo-type kitty --logo ... --logo-width 35` | `sixel` in Windows Terminal, `iterm` (aspect-preserving box) in WezTerm, no image elsewhere | | Logs | `~/.config/j621Logos/logs.log` | `%APPDATA%\j621Logos\logs.log` | ## Install @@ -99,8 +99,10 @@ switch, or just edit the file. - **No image logo in Windows Terminal**: WT 1.22+ is required for sixel; update with `winget upgrade Microsoft.WindowsTerminal`. - **WezTerm**: kitty graphics must be on - `config.enable_kitty_graphics = true` - in `~/.wezterm.lua`. If the default looks wrong, try - `J621_LOGO_TYPE=kitty`, `sixel`, or `iterm`. + in `~/.wezterm.lua`. The default uses the `iterm` logo type with + `preserveAspectRatio`, which never stretches. If something looks off, try + `J621_LOGO_TYPE=kitty-direct`, `kitty`, or `sixel` (note: through ConPTY, + plain `kitty` falls back to ASCII and `kitty-direct` stretches tall images). - **VS Code / other terminals**: no image protocol, so the greeting prints a plain fastfetch on purpose (no fetch delay). `J621_ALWAYS_FETCH=1` still fetches and prints the link. diff --git a/extras/powershell_greeting/config.example.ps1 b/extras/powershell_greeting/config.example.ps1 index 8e5a857..e215a2e 100644 --- a/extras/powershell_greeting/config.example.ps1 +++ b/extras/powershell_greeting/config.example.ps1 @@ -20,5 +20,7 @@ if (-not $env:J621_BASE) { $env:J621_BASE = 'https://j621.rainbow-herring.ts.net # if (-not $env:J621_FASTFETCH_CONFIG) { $env:J621_FASTFETCH_CONFIG = 'jake' } # Force a fastfetch logo type instead of the per-terminal default -# (Windows Terminal -> sixel, WezTerm -> kitty-direct, others -> no image). -# if (-not $env:J621_LOGO_TYPE) { $env:J621_LOGO_TYPE = 'kitty-direct' } +# (Windows Terminal -> sixel, WezTerm -> iterm with preserveAspectRatio, +# others -> no image). +# if (-not $env:J621_LOGO_TYPE) { $env:J621_LOGO_TYPE = 'iterm' } +# if (-not $env:J621_LOGO_HEIGHT) { $env:J621_LOGO_HEIGHT = '25' }