Files
Nomarchy/modules/home/timezone.nix
Bernardo Magri 76941c55b7 fix(waybar): bar pokes missed the wrapped process — switches never touched the bar
nixpkgs wraps waybar, so the running comm is `.waybar-wrapped`:
`pkill -x waybar` (state-sync restart/SIGUSR2 branches, tz-watch,
updates) matched nothing — a theme switch neither restarted nor reloaded
the bar, which then kept the gtk.css of whatever theme it started under
(the stale workspace-digit colors reported 2026-07-18; companion gtk fix
in the next commit). The unanchored pokes (recording, airplane,
theme-shot) had the opposite bug: `waybar` substring-matches the
supervisor's `nomarchy-waybar` comm too, and an unhandled RTMIN
terminates its bash — the pokes were killing the crash guard. All seven
sites now use `pkill … -x 'waybar|\.waybar-wrapped'`.
state-sync 0.5.1 → 0.5.2.

Verified live on Newton (V3-grade): new pattern restarts the bar under
the supervisor (fresh pid, supervisor alive); RTMIN+10 poke reaches the
bar, supervisor survives. V0 `nix flake check --no-build` + py_compile;
V1 HM generation + system toplevel build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 11:04:08 +01:00

46 lines
1.9 KiB
Nix

# Auto-timezone, home side: keep the Waybar clock in step with the system
# timezone. Waybar's clock module captures the zone once at construction, so a
# runtime timezone change (automatic-timezoned, nomarchy.system.autoTimezone)
# would NOT show until a relogin. A tiny watcher subscribes to timedate1's
# change signal and reloads Waybar (SIGUSR2 = the same reload state-sync uses),
# so the clock follows your location live. Also catches a manual
# `timedatectl set-timezone`.
#
# Gated on the same in-flake flag the system side reads (settings.autoTimezone,
# exposed via nomarchy.settings) — so it only runs when the feature is on. The
# menu toggle (nomarchy-autotimezone) rebuilds both sides off that one flag.
{ config, lib, pkgs, ... }:
let
cfg = config.nomarchy;
enabled = cfg.waybar.enable && (cfg.settings.autoTimezone or false);
tzWatch = pkgs.writeShellScript "nomarchy-tz-watch" ''
last=$(${pkgs.systemd}/bin/timedatectl show -p Timezone --value 2>/dev/null || true)
${pkgs.dbus}/bin/dbus-monitor --system \
"type='signal',interface='org.freedesktop.DBus.Properties',path='/org/freedesktop/timedate1',member='PropertiesChanged'" \
2>/dev/null |
while read -r _; do
cur=$(${pkgs.systemd}/bin/timedatectl show -p Timezone --value 2>/dev/null || true)
[ "$cur" = "$last" ] && continue
last=$cur
# Both comm names: nixpkgs wraps the binary as `.waybar-wrapped`.
${pkgs.procps}/bin/pkill -SIGUSR2 -x 'waybar|\.waybar-wrapped' 2>/dev/null || true
done
'';
in
{
systemd.user.services.nomarchy-tz-watch = lib.mkIf enabled {
Unit = {
Description = "Reload Waybar on timezone change (auto-timezone)";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${tzWatch}";
Restart = "on-failure";
};
Install.WantedBy = [ "graphical-session.target" ];
};
}