Let somebody extend this without forking it, and say when things die

Two of Section F.

Hooks are the pressure valve. "Can Panama also do X when the theme
changes" is now a five-line file in ~/.config/panama/hooks rather than
a fork, a feature request, or a patch somebody rebases forever. Each
name takes a single file and a .d directory so several things can react
without fighting over one, and a broken hook is reported and stepped
over: somebody's script must never cost a theme change, an upgrade or a
login. Wired at theme-set, post-upgrade and post-migrate. This is the
thirty-line version of the plugin host the upstream ledger defers, and
it has no API to keep stable beyond "we will run your script and tell
you what happened".

Testing it caught a real bug the reading would not have: run_one
captured the script path but never shifted it off, so every hook got
its own filename as $1 and the real arguments arrived one place late. A
hook reading $1 as the colour scheme got a path.

The crash watcher notices when a program dumps core and says so. Under
GNOME, ABRT does this; here nothing did, and applications died silently,
which is most of how "Linux is flaky" gets earned.

Once per program per session is the entire design, not a nicety. This
machine's portal backend crashes between eleven and sixty times a day,
and a notification per crash would be one every few minutes for
something nobody can act on. The first is news; the fortieth is why
people turn notifications off. The health page keeps the running count.

It waits for the notification server before reporting, because the
crash most worth hearing about is the one that took the shell with it,
and it names the executable rather than the kernel's comm field, which
truncates at fifteen characters. Verified against real segfaults.
This commit is contained in:
Gabriel Brown
2026-08-22 08:11:49 -04:00
parent 41dd91eb75
commit 7a5e990439
14 changed files with 499 additions and 2 deletions
+4
View File
@@ -44,6 +44,10 @@ hl.on("hyprland.start", function()
-- than enabled so it belongs to the Hyprland session; see the unit.
hl.exec_cmd("systemctl --user start panama-migrate-notify.service")
-- Notices when a program dumps core and says so once per session. Under
-- GNOME, ABRT does this; here nothing did, and applications died silently.
hl.exec_cmd("systemctl --user start panama-crash-watch.service")
-- Text expansion. change-settings runs `espanso service register`, which
-- writes and enables espanso's own user unit; the explicit start makes the
-- first Hyprland login after a fresh install work rather than the second.
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Runs after `panama migrate` has applied repairs, and only when it applied at
# least one. Takes no arguments.
#
# Useful when a machine keeps local state that a repair might have invalidated.
#
# Copy to ~/.config/panama/hooks/post-migrate and make it executable.
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Runs at the end of ./install, after every stage and after migrations.
#
# Takes no arguments. This is where per-machine setup goes that Panama should
# not carry for everyone: a work laptop's VPN client, a private repository
# somebody clones, a package only this machine wants.
#
# Copy to ~/.config/panama/hooks/post-upgrade and make it executable.
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Runs whenever the colour scheme or accent changes.
#
# $1 scheme: "dark" or "light"
# $2 accent: blue, orchid, teal, green, amber, orange, rose or slate
#
# Copy to ~/.config/panama/hooks/theme-set and make it executable. Anything in
# theme-set.d/ runs too, in sorted order, so several things can react without
# fighting over one file.
#
# A failure here is reported and stepped over: it will never cost you a theme
# change.
scheme="$1"
accent="$2"
# For example: repaint something Panama does not know about.
# printf 'set-theme %s\n' "$scheme" | nc -U "$HOME/.local/share/some-app/socket"
@@ -234,7 +234,13 @@ if [[ -r "$theme_file" ]]; then
# bottom, so a later active_border_color line wins, and this file is
# itself generated -- the tracked per-scheme theme stays scheme-only.
if cp "$theme_file" "$kitty_dir/current-theme.conf.tmp" 2>/dev/null \
&& printf 'active_border_color #%s\n' "$accent_border_hex" >>"$kitty_dir/current-theme.conf.tmp" \
&& # Anything else on this machine that wants to know. Runs after every generator
# above, so a hook sees the finished state rather than a half-applied one, and
# a broken hook cannot cost you a theme change -- panama-hook reports and steps
# over. See bin/panama-hook.
"${PANAMA_PATH:-$HOME/.local/share/Panama}/bin/panama-hook" theme-set "$scheme" "$accent" || true
printf 'active_border_color #%s\n' "$accent_border_hex" >>"$kitty_dir/current-theme.conf.tmp" \
&& mv "$kitty_dir/current-theme.conf.tmp" "$kitty_dir/current-theme.conf" 2>/dev/null; then
status_kitty="written"
else