theming: reload the scratchpad ghostty too
theme-apply sent reload-config to com.mitchellh.ghostty only, and its comment claimed the scratchpad 'is the same process'. It is not — that is the whole point of the --class in settings/hyprland.nix. Ghostty's --class IS the GTK application id, which is how it forces a separate instance, and a separate instance owns its own bus name and object path. So the scratchpad never got the reload and kept the old palette until it was killed. Now both are told, scratchpad first and best-effort, since it only exists once SUPER+Return has been pressed this session.
This commit is contained in:
parent
5d81cda5c2
commit
d7df9ee4b4
1 changed files with 28 additions and 14 deletions
|
|
@ -536,24 +536,38 @@ let
|
||||||
reply=$(${pkgs.hyprland}/bin/hyprctl eval "$(cat "$theme/hypr.lua")" 2>&1)
|
reply=$(${pkgs.hyprland}/bin/hyprctl eval "$(cat "$theme/hypr.lua")" 2>&1)
|
||||||
[ "$reply" = "ok" ] || echo "hyprctl eval -> $reply"
|
[ "$reply" = "ok" ] || echo "hyprctl eval -> $reply"
|
||||||
|
|
||||||
# Ghostty holds its config in one process (gtk-single-instance), so a new
|
# Ghostty holds its config in one process, so a new window inherits
|
||||||
# window inherits whatever the daemon parsed at startup — reopening a
|
# whatever that process parsed at startup — reopening a terminal is NOT
|
||||||
# terminal is NOT enough to pick up a new theme.
|
# enough to pick up a new theme.
|
||||||
#
|
#
|
||||||
# It is a GTK application, so it publishes its actions on the session bus;
|
# There are TWO processes to tell, not one. gtk-single-instance funnels
|
||||||
# `reload-config` is the same action the reload_config keybind fires. Going
|
# every plain `ghostty` into the com.mitchellh.ghostty instance, but the
|
||||||
# through D-Bus works with no window open, needs no window focused, and
|
# scratchpad launches with --class=dev.fred.scratchpad, and ghostty's
|
||||||
# doesn't depend on synthesising a keypress into the right surface.
|
# --class IS the GTK application id — which is exactly how it forces a
|
||||||
if ! ${pkgs.glib.bin}/bin/gdbus call --session \
|
# separate instance (see settings/hyprland.nix). A separate instance
|
||||||
--dest com.mitchellh.ghostty \
|
# means its own bus name and its own object path, so a reload aimed at
|
||||||
--object-path /com/mitchellh/ghostty \
|
# com.mitchellh.ghostty never reaches it and the scratchpad sat on the
|
||||||
|
# old palette until it was killed.
|
||||||
|
#
|
||||||
|
# Both are GTK applications publishing their actions on the session bus;
|
||||||
|
# `reload-config` is the same action the reload_config keybind fires.
|
||||||
|
# Going through D-Bus works with no window open, needs no window focused,
|
||||||
|
# and doesn't depend on synthesising a keypress into the right surface.
|
||||||
|
ghostty_reload() {
|
||||||
|
${pkgs.glib.bin}/bin/gdbus call --session \
|
||||||
|
--dest "$1" --object-path "$2" \
|
||||||
--method org.gtk.Actions.Activate \
|
--method org.gtk.Actions.Activate \
|
||||||
reload-config '[]' '{}' >/dev/null 2>&1; then
|
reload-config '[]' '{}' >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Absent is not a failure: the scratchpad only exists once SUPER+Return
|
||||||
|
# has been pressed this session.
|
||||||
|
ghostty_reload dev.fred.scratchpad /dev/fred/scratchpad || true
|
||||||
|
|
||||||
|
if ! ghostty_reload com.mitchellh.ghostty /com/mitchellh/ghostty; then
|
||||||
# No instance on the bus, or the action is gone. Restarting the daemon
|
# No instance on the bus, or the action is gone. Restarting the daemon
|
||||||
# fixes it but takes every open terminal with it, so that is only on the
|
# fixes it but takes every open terminal with it, so that is only on the
|
||||||
# table when there is nothing to lose. The class test has to cover the
|
# table when there is nothing to lose. The class test covers both ids.
|
||||||
# --class override from settings/hyprland.nix (dev.fred.scratchpad) —
|
|
||||||
# that window is the same process.
|
|
||||||
if ${pkgs.hyprland}/bin/hyprctl -j clients 2>/dev/null \
|
if ${pkgs.hyprland}/bin/hyprctl -j clients 2>/dev/null \
|
||||||
| ${pkgs.jq}/bin/jq -e 'any(.[].class; test("ghostty|^dev\\.fred\\."))' >/dev/null 2>&1; then
|
| ${pkgs.jq}/bin/jq -e 'any(.[].class; test("ghostty|^dev\\.fred\\."))' >/dev/null 2>&1; then
|
||||||
echo "ghostty reload-config failed; open terminals keep the old theme"
|
echo "ghostty reload-config failed; open terminals keep the old theme"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue