Give the app an icon and a place in the application menu
icon.svg is the source; make_icons.py rasterises it into assets/icon-<size>.png at the six sizes a window manager asks for. Tk 8.6 reads PNG but not SVG, so the icon has to ship pre-rendered, and the glyph is laid on a rounded plate in the app's own colours — light on dark stays legible against both a light and a dark dock, which slate grey on nothing does not. ui.py loads whichever of those files exist and passes them all to iconphoto(), letting the WM pick per context (title bar, alt-tab, dock). The images are kept on the instance because Tk holds only a weak reference to a PhotoImage and the icon blanks out when it is collected. A missing or unreadable file is ignored rather than allowed to fail a launch. It also passes className="lektor-ai", which lands in WM_CLASS. Without it Tk calls itself "Tk" and that is what the dock shows on hover; the readable name comes from the desktop entry, which matches the window through StartupWMClass. install_desktop.sh writes ~/.local/share/applications/lektor-ai.desktop and copies the icons into the hicolor theme, so the app appears in the menu and can be pinned. Everything it installs lives under ~/.local and comes back out with --uninstall. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NkWDx9dVB7xBpqntvjvm6A
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# install_desktop.sh — put "Lektor AI" in the application menu and the dock.
|
||||
#
|
||||
# Two things live outside this folder afterwards, both under ~/.local and both
|
||||
# removable with --uninstall:
|
||||
#
|
||||
# ~/.local/share/applications/lektor-ai.desktop
|
||||
# ~/.local/share/icons/hicolor/<size>/apps/lektor-ai.png
|
||||
#
|
||||
# The desktop entry matches the running window through StartupWMClass, which is
|
||||
# the WM_CLASS that ui.py sets. Without the match the dock falls back to the raw
|
||||
# WM_CLASS for its hover label.
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(dirname "$(readlink -f "$0")")"
|
||||
APPS="$HOME/.local/share/applications"
|
||||
ICONS="$HOME/.local/share/icons/hicolor"
|
||||
ENTRY="$APPS/lektor-ai.desktop"
|
||||
SIZES=(16 32 48 64 128 256)
|
||||
|
||||
if [[ "${1:-}" == "--uninstall" ]]; then
|
||||
rm -f "$ENTRY"
|
||||
for s in "${SIZES[@]}"; do
|
||||
rm -f "$ICONS/${s}x${s}/apps/lektor-ai.png"
|
||||
done
|
||||
echo "Removed the desktop entry and its icons."
|
||||
else
|
||||
for s in "${SIZES[@]}"; do
|
||||
src="$HERE/assets/icon-$s.png"
|
||||
[[ -f "$src" ]] || continue
|
||||
mkdir -p "$ICONS/${s}x${s}/apps"
|
||||
cp "$src" "$ICONS/${s}x${s}/apps/lektor-ai.png"
|
||||
done
|
||||
|
||||
mkdir -p "$APPS"
|
||||
cat > "$ENTRY" <<DESKTOP
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Lektor AI
|
||||
Comment=Polish AI voiceover queue
|
||||
Exec=$HERE/start_lektor_ui.sh
|
||||
Icon=lektor-ai
|
||||
Terminal=false
|
||||
Categories=AudioVideo;Audio;
|
||||
StartupWMClass=Lektor-ai
|
||||
DESKTOP
|
||||
chmod +x "$ENTRY"
|
||||
echo "Installed $ENTRY"
|
||||
fi
|
||||
|
||||
# Harmless if the tools are missing; the dock picks the change up either way.
|
||||
update-desktop-database "$APPS" 2>/dev/null || true
|
||||
gtk-update-icon-cache -f -t "$ICONS" 2>/dev/null || true
|
||||
Reference in New Issue
Block a user