feat(state): opt-in auto-commit of state mutations (Phase 4)
settings.autoCommit — toggled from System › Auto-commit (self-gated on the flake being a git repo) — makes every nomarchy-theme-sync apply/set also git-commit theme-state.json in the downstream flake, so settings history is `git log`. Off by default. Design: the flag is live-read by the tool on each write (nothing in Nix consumes it → instant toggle, no rebuild, no new option); the commit is pathspec-limited to theme-state.json so unrelated dirty files are never swept up; it fires when the flag is on before OR after the write, so the disable-toggle itself lands in history; same-value writes no-op (diff against HEAD); missing git identity falls back to Nomarchy <nomarchy@localhost>; `bg next` is deliberately excluded. Rider fix: `get` now prints booleans JSON-style (true, not Python's True) — un-sticking the System menu's "Auto timezone (on/off)" label, whose `= true` comparison could never match. All shell consumers already normalise true|True, so no other behavior change. Verified: V0 (py_compile, nix flake check) + V1 (HM generation builds, generated nomarchy-menu passes bash -n, wiring present in the rendered script) + a 7-assertion sandbox-repo round-trip covering enable/set/ same-value/disable/post-disable/apply paths and the identity fallback. Remaining: on-machine check queued in agent/HARDWARE-QUEUE.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -387,6 +387,22 @@ ${themeRows}
|
||||
|| { notify-send "Auto timezone" "Unavailable on this machine."; exit 0; }
|
||||
exec ${cfg.terminal} -e nomarchy-autotimezone toggle ;;
|
||||
|
||||
autocommit)
|
||||
# Toggle opt-in auto-commit: every menu/theme mutation also commits
|
||||
# theme-state.json (that file only) in the downstream flake, so
|
||||
# settings history is `git log`. Nothing in Nix consumes the flag —
|
||||
# the tool reads the live state on each write — so the toggle is
|
||||
# instant, no rebuild. The off-write commits too (the tool fires
|
||||
# when the flag was on before OR after), keeping history consistent.
|
||||
if [ "$(nomarchy-theme-sync get settings.autoCommit 2>/dev/null)" = true ]; then
|
||||
nomarchy-theme-sync --quiet set settings.autoCommit false --no-switch
|
||||
notify-send "Auto-commit" "Off — menu changes stay uncommitted in your flake."
|
||||
else
|
||||
nomarchy-theme-sync --quiet set settings.autoCommit true --no-switch
|
||||
notify-send "Auto-commit" "On — each change commits theme-state.json in your flake."
|
||||
fi
|
||||
exit 0 ;;
|
||||
|
||||
snapshot)
|
||||
# btrfs-assistant 2.2 segfaults on 26.05 (libbtrfsutil ABI), so launch
|
||||
# the keyboard-driven snapper browser instead: a terminal running it
|
||||
@@ -443,6 +459,12 @@ ${themeRows}
|
||||
then row "Auto timezone (on)" preferences-system-time
|
||||
else row "Auto timezone (off)" preferences-system-time
|
||||
fi
|
||||
if [ -e "''${NOMARCHY_PATH:-$HOME/.nomarchy}/.git" ]; then
|
||||
if [ "$(nomarchy-theme-sync get settings.autoCommit 2>/dev/null)" = true ]
|
||||
then row "Auto-commit (on)" git
|
||||
else row "Auto-commit (off)" git
|
||||
fi
|
||||
fi
|
||||
command -v nomarchy-snapshots >/dev/null 2>&1 && row "Snapshots" timeshift
|
||||
if [ -e "''${bats[0]}" ] && command -v powerprofilesctl >/dev/null 2>&1; then
|
||||
row "Power profile" preferences-system-power
|
||||
@@ -460,6 +482,7 @@ ${themeRows}
|
||||
*"Do Not Disturb"*) exec "$0" dnd ;;
|
||||
*"Night light"*) exec "$0" nightlight ;;
|
||||
*"Auto timezone"*) exec "$0" autotimezone ;;
|
||||
*"Auto-commit"*) exec "$0" autocommit ;;
|
||||
*Snapshots*) exec "$0" snapshot ;;
|
||||
*"Power profile"*) exec "$0" power-profile ;;
|
||||
esac ;;
|
||||
@@ -486,7 +509,7 @@ ${themeRows}
|
||||
esac ;;
|
||||
|
||||
*)
|
||||
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|printers|capture|keybinds|ask|dnd|nightlight|autotimezone|vpn|snapshot]" >&2
|
||||
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|printers|capture|keybinds|ask|dnd|nightlight|autotimezone|autocommit|vpn|snapshot]" >&2
|
||||
exit 64 ;;
|
||||
esac
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user