Compare commits

..

2 Commits

Author SHA1 Message Date
Bernardo Magri
c2f90c7d0a feat(menu): printer setup — system-config-printer in the System submenu
A `nomarchy-menu printers` entry opens system-config-printer (the CUPS
admin GUI), mirroring the bluetooth/blueman pattern: the printing service
ships the package via environment.systemPackages and the menu execs it,
self-gated on the system-config-printer binary so the entry appears only
when nomarchy.services.printing is on. No direct keybind (rare one-off).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 20:09:35 +01:00
Bernardo Magri
5747dc9839 feat(nightlight): persistent off via state marker
A manual `off` now drops ~/.local/state/nomarchy/nightlight-off and the
hyprsunset unit refuses to (re)start while it exists
(Unit.ConditionPathExists=!%h/...), so the off survives logout/reboot
until toggled back on. `on`/toggle-on remove the marker before starting
(a failed condition would otherwise no-op the start). Without the marker
behaviour is unchanged: the service stays WantedBy=graphical-session.target
and resumes its schedule at login, so persistence is opt-in via the toggle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 20:09:22 +01:00
4 changed files with 57 additions and 16 deletions

View File

@@ -85,6 +85,18 @@ how to override it. Items marked ✓ are shipped.
so it'd mean adopting a new secret manager. Revisit if that changes.
- Also: menu search is now **case-insensitive fuzzy** (`matching = fuzzy`,
`sorting-method = fzf`) across every module + the launcher.
-**Printer setup menu module:** a `nomarchy-menu printers` entry in the
**System** submenu opens **system-config-printer** (the CUPS admin GUI —
discovery, drivers/PPDs, options, test page), mirroring the bluetooth/blueman
pattern: the printing service ships the package (`environment.systemPackages`)
and the menu execs it, self-gated on the `system-config-printer` binary so
the entry appears only when `nomarchy.services.printing` is on. No direct
`SUPER+CTRL` bind — printer setup is a rare one-off, not a frequent utility
(left out deliberately; easy to add). Chose the GUI over a rofi-native
`lpadmin` flow (driver/PPD picking is impractical in rofi) and the CUPS web
UI (an unthemed browser page). Validated: the generated menu script's
`bash -n` build check passes, and an eval confirms printing-on puts
system-config-printer in `systemPackages`. Pending an on-machine check.
- **Theme parity with legacy:** summer-day/night now carry their legacy
bar layouts as `waybar.jsonc` whole-swaps (adapted: dead legacy script
modules dropped, Nerd-Fonts-v2 codepoints remapped to FontAwesome/v3,
@@ -459,15 +471,17 @@ how to override it. Items marked ✓ are shipped.
`nomarchy-menu nightlight` entry (System submenu, self-gated on the unit
existing) and a self-gating Waybar `custom/nightlight` indicator (moon = on,
sun = off; in the generated bar and both summer whole-swaps) drive it.
The toggle is **session-scoped by design**: `stop` halts the running unit
but it's `WantedBy=graphical-session.target`, so the next login auto-starts
it and night-light returns to its schedule (off never persists). Remaining
(optional): (1) **persistent off** — a state marker
(`~/.local/state/nomarchy/nightlight-off`) the unit honours via
`ConditionPathExists=!%h/…`, so a manual off survives logout/reboot until
toggled back; (2) geo (lat/long) auto sunset/sunrise (would mean wlsunset,
which schedules by location). Pending an on-machine check that stopping
hyprsunset cleanly restores the gamma.
**Persistent off:** a manual `off` now drops a marker
(`~/.local/state/nomarchy/nightlight-off`) and the unit refuses to (re)start
while it exists (`Unit.ConditionPathExists=!%h/…`), so an off survives
logout/reboot until toggled back on; `on`/toggle-on remove the marker first
(a failed condition would otherwise no-op the start). Without the marker the
service stays `WantedBy=graphical-session.target` and resumes its schedule at
login as before — the session-scoped behaviour is now the *default*, with
persistence opt-in via the toggle. Remaining (optional): geo (lat/long) auto
sunset/sunrise (would mean wlsunset, which schedules by location). Pending an
on-machine check (off persisting across reboot, and that stopping hyprsunset
cleanly restores the gamma).
- **Keyboard layouts (per-device + switching):**
-**Per-device declarative layout:** `nomarchy.keyboard.devices`
(`{ "<hyprctl-device-name>" = { layout; variant; }; }`) generates Hyprland

View File

@@ -21,6 +21,12 @@ let
# module hides itself — same pattern as the power-profile indicator.
nomarchy-nightlight = pkgs.writeShellScriptBin "nomarchy-nightlight" ''
unit=hyprsunset.service
# Persistent-off marker mirrors the unit's ConditionPathExists below.
# Present => night-light stays off across logout/reboot until toggled on.
# Path is literal (not XDG_STATE_HOME) so it matches the unit's %h check.
marker="$HOME/.local/state/nomarchy/nightlight-off"
mark_off() { mkdir -p "$(dirname "$marker")"; : > "$marker"; }
mark_on() { rm -f "$marker"; }
if ! systemctl --user cat "$unit" >/dev/null 2>&1; then
[ "''${1:-}" = status ] && exit 0
notify-send "Night light" "Not enabled set nomarchy.nightlight.enable."
@@ -33,14 +39,14 @@ let
else
printf '{"text":"󰖙","tooltip":"Night light off (click to enable)","class":"off"}\n'
fi ;;
on) systemctl --user start "$unit" ;;
off) systemctl --user stop "$unit" ;;
on) mark_on; systemctl --user start "$unit" ;;
off) mark_off; systemctl --user stop "$unit" ;;
toggle)
if systemctl --user is-active --quiet "$unit"; then
systemctl --user stop "$unit"
notify-send "Night light off" "Screen back to true colours."
mark_off; systemctl --user stop "$unit"
notify-send "Night light off" "Screen back to true colours (stays off until re-enabled)."
else
systemctl --user start "$unit"
mark_on; systemctl --user start "$unit"
notify-send "Night light on" "Warm filter follows your schedule."
fi ;;
*) echo "usage: nomarchy-nightlight [toggle|status|on|off]" >&2; exit 64 ;;
@@ -59,6 +65,13 @@ in
];
};
# Persistent off: a manual `off` drops ~/.local/state/nomarchy/nightlight-off,
# and this Condition makes the unit refuse to (re)start while it exists — so
# an off survives logout/reboot. `nomarchy-nightlight on` removes it first
# (a failed condition would otherwise no-op the start). %h = $HOME.
systemd.user.services.hyprsunset.Unit.ConditionPathExists =
lib.mkIf cfg.enable "!%h/.local/state/nomarchy/nightlight-off";
# Always on PATH (it self-gates at runtime), so a static whole-swap Waybar
# can exec it even when night-light is off without the call failing.
home.packages = [ nomarchy-nightlight ];

View File

@@ -250,6 +250,14 @@ ${themeRows}
# blueman-manager GUI (services.blueman.enable, system-side).
exec blueman-manager ;;
printers)
# system-config-printer GUI (the CUPS admin app), installed by
# nomarchy.services.printing. Self-gated in the System menu; guard
# here too in case it's invoked directly.
command -v system-config-printer >/dev/null 2>&1 \
&& exec system-config-printer
notify-send "Printers" "Not available (nomarchy.services.printing off?)."; exit 0 ;;
audio)
# PipeWire (pulse) sink/source switcher via rofi-pulse-select. Self-
# gated in the System menu on the pulse socket; guarded here too.
@@ -360,6 +368,7 @@ ${themeRows}
row "Bluetooth" bluetooth
[ -e "''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/pulse/native" ] \
&& row "Audio" audio-volume-high
command -v system-config-printer >/dev/null 2>&1 && row "Printers" printer
row "Do Not Disturb" notification-disabled
systemctl --user cat hyprsunset.service >/dev/null 2>&1 \
&& row "Night light" weather-clear-night
@@ -374,6 +383,7 @@ ${themeRows}
*Network*) exec "$0" network ;;
*Bluetooth*) exec "$0" bluetooth ;;
*Audio*) exec "$0" audio ;;
*Printers*) exec "$0" printers ;;
*"Do Not Disturb"*) exec "$0" dnd ;;
*"Night light"*) exec "$0" nightlight ;;
*Snapshots*) exec "$0" snapshot ;;
@@ -402,7 +412,7 @@ ${themeRows}
esac ;;
*)
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|capture|keybinds|ask|dnd|nightlight|snapshot]" >&2
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|printers|capture|keybinds|ask|dnd|nightlight|snapshot]" >&2
exit 64 ;;
esac
'';

View File

@@ -75,7 +75,8 @@ in
printing.enable = lib.mkEnableOption ''
CUPS printing with Avahi/mDNS, so network printers are auto-discovered
(add vendor drivers via `services.printing.drivers`)'';
(add vendor drivers via `services.printing.drivers`); the menu's
System Printers entry opens the system-config-printer GUI'';
openrgb.enable = lib.mkEnableOption ''
the OpenRGB daemon and GUI for controlling RGB lighting on peripherals
@@ -246,6 +247,9 @@ in
nssmdns4 = true;
openFirewall = true;
};
# The CUPS admin GUI — the menu's System ▸ Printers entry execs it
# (self-gated on this binary), so it ships with the printing service.
environment.systemPackages = [ pkgs.system-config-printer ];
})
(lib.mkIf cfg.openrgb.enable {