All checks were successful
Check / eval (push) Successful in 3m53s
modules/home/autotheme.nix installs a user service + timer (nomarchy-auto-theme) that periodically runs `nomarchy-theme-sync auto`, so the day/night theme is applied on the current schedule through the same one engine. Install gates on settings.autoTheme.enable (read from state, the way updates.nix gates on its enable), so a machine not using the feature carries no timer. Timer: OnStartupSec=1min (settle after login) + OnCalendar=*:0/15 + Persistent (catch a transition missed while off). Periodic rather than exact sunrise/sunset timers — robust to suspend/DST, and `auto` is idempotent (no rebuild unless the theme must change) so ticks are cheap. Verification: V1 — real-config eval (state temporarily enabled, then restored) confirms the units land when enabled (OnCalendar *:0/15, ExecStart `... nomarchy-theme-sync auto`) and are absent when disabled; systemd-analyze validates the schedule. V0 flake check green. The live timer -> home-manager switch on a real Nomarchy session is pending a Nomarchy machine (same blocker as #76). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.7 KiB
Nix
37 lines
1.7 KiB
Nix
# Auto time-of-day theme switch (BACKLOG #79, VISION § D). A user timer
|
|
# periodically runs `nomarchy-theme-sync auto`, which reads
|
|
# settings.autoTheme = { enable, day, night, sunrise, sunset } from the
|
|
# state file and applies the day or night preset for the current clock —
|
|
# through the SAME one engine as a manual `apply` (no second pipeline).
|
|
#
|
|
# The command self-gates (no-op when disabled) and is idempotent (it only
|
|
# rebuilds when the active theme actually needs to change), so the timer
|
|
# can tick freely. Install is gated on the state flag (like nomarchy.updates
|
|
# gates on its enable), so a machine not using the feature carries no timer;
|
|
# enabling it from the menu (slice 3) writes the flag + rebuilds, which is
|
|
# what brings the timer into being.
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
lib.mkIf (config.nomarchy.settings.autoTheme.enable or false) {
|
|
systemd.user.services.nomarchy-auto-theme = {
|
|
Unit.Description = "Apply the day/night theme for the current time";
|
|
Service = {
|
|
Type = "oneshot";
|
|
# The rebuild (`home-manager switch`) and its tools resolve from the
|
|
# system + per-user profiles — same PATH shape nomarchy-updates uses.
|
|
Environment = "PATH=/run/current-system/sw/bin:/etc/profiles/per-user/${config.home.username}/bin";
|
|
ExecStart = "${pkgs.nomarchy-theme-sync}/bin/nomarchy-theme-sync auto";
|
|
};
|
|
};
|
|
|
|
systemd.user.timers.nomarchy-auto-theme = {
|
|
Unit.Description = "Periodic day/night theme check";
|
|
Timer = {
|
|
OnStartupSec = "1min"; # settle on the right theme shortly after login
|
|
OnCalendar = "*:0/15"; # re-check every 15 min; auto no-ops if unchanged
|
|
Persistent = true; # catch a transition missed while powered off
|
|
};
|
|
Install.WantedBy = [ "timers.target" ];
|
|
};
|
|
}
|