Give the app an icon, and a script that installs it

The launcher pointed at `Icon=story-editor`, a name that only the Breeze
theme happened to ship, and only at 16 and 22 px -- so anywhere the
desktop wanted a larger icon it fell back to something generic.

assets/md-manuscript.svg is the source: a sheaf of manuscript pages, an
amber chapter-title line over three of prose. Drawn in plain rounded
rectangles because a finer design silts up into a grey smear at 16 px.
It is rasterised to the eight sizes a desktop asks for, and the 256px
PNG is compiled into the binary as the window icon, so the title bar and
the task switcher carry it whether or not anything is installed. That
costs no new dependency: eframe already pulls `image` with png decoding.
A test decodes the bundled PNG, since a rename would otherwise show up
only as a blank icon at runtime.

Installation is now `./assets/install.sh` -- binary, icons, launcher and
both cache refreshes, safe to re-run after a rebuild. The launcher is a
file in the repository rather than a here-document in the instructions:
pasting one into a terminal leaves the shell sat at a `>` prompt waiting
for a terminator that never arrives, which is exactly what happened, and
this way the launcher is versioned along with everything else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GYSGPDwkSzhm4qLqjCbqxU
This commit is contained in:
2026-08-25 18:15:21 -05:00
parent f35397b49b
commit be6a2d6a8b
14 changed files with 182 additions and 18 deletions
+62 -14
View File
@@ -92,26 +92,74 @@ applications menu (GNOME app grid / XFCE Whisker Menu) and can be pinned for
touch:
```sh
# 4a. Binary
./assets/install.sh
```
That puts the binary on your `PATH`, installs the icon at every size the desktop
might ask for, and adds the launcher — then refreshes both caches. It is safe to
re-run after every rebuild, which is how you pick up a new version. Installing
somewhere else is `PREFIX=/usr/local sudo ./assets/install.sh`.
<details>
<summary>What it does, if you would rather do it by hand</summary>
```sh
install -Dm755 target/release/md-manuscript ~/.local/bin/md-manuscript
# 4b. Desktop launcher
mkdir -p ~/.local/share/applications
cat > ~/.local/share/applications/md-manuscript.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=md-manuscript
Comment=Draggable markdown manuscript editor with git sync and ODT export
Exec=md-manuscript
Icon=text-editor
Categories=Office;TextEditor;
Terminal=false
EOF
for size in 16 22 24 32 48 64 128 256; do
install -Dm644 "assets/icons/hicolor/${size}x${size}/apps/md-manuscript.png" \
~/.local/share/icons/hicolor/${size}x${size}/apps/md-manuscript.png
done
install -Dm644 assets/icons/hicolor/scalable/apps/md-manuscript.svg \
~/.local/share/icons/hicolor/scalable/apps/md-manuscript.svg
# 4c. Refresh the app list
install -Dm644 assets/md-manuscript.desktop \
~/.local/share/applications/md-manuscript.desktop
gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor 2>/dev/null || true
update-desktop-database ~/.local/share/applications 2>/dev/null || true
```
The launcher is `assets/md-manuscript.desktop`, kept in the repository and
copied into place rather than typed out at the prompt — a here-document is an
awkward thing to paste into a terminal, and this way the launcher is versioned
along with everything else.
</details>
`Icon=md-manuscript` in the launcher is a *name*, not a path: the desktop looks
it up in the icon theme and picks whichever size it wants, which is why the whole
set gets installed rather than one file. `StartupWMClass` matches the running
window to the launcher, so a pinned icon highlights rather than spawning a second
entry.
The window carries the icon itself as well — the 256px PNG is compiled into the
binary — so the title bar and the task switcher show it even before any of this
is installed.
### Regenerating the icon
`assets/md-manuscript.svg` is the source. After editing it, rebuild the PNG set
(ImageMagick rasterises the SVG; Pillow does the downscaling, which is markedly
cleaner at 16 and 24 px):
```sh
python3 - <<'REGEN'
import os, subprocess
from PIL import Image
subprocess.run(["convert", "-background", "none", "-density", "1200",
"assets/md-manuscript.svg", "-resize", "512x512",
"/tmp/md-manuscript-master.png"], check=True)
im = Image.open("/tmp/md-manuscript-master.png").convert("RGBA")
for size in (16, 22, 24, 32, 48, 64, 128, 256):
d = f"assets/icons/hicolor/{size}x{size}/apps"
os.makedirs(d, exist_ok=True)
im.resize((size, size), Image.LANCZOS).save(f"{d}/md-manuscript.png")
REGEN
cp assets/md-manuscript.svg assets/icons/hicolor/scalable/apps/md-manuscript.svg
cargo build --release # the 256px PNG is baked into the binary
```
Make sure `~/.local/bin` is on your `PATH` (it is by default on Debian 12 if the
directory exists at login — otherwise add this to `~/.bashrc` and re-login):