feat(core): migrate system state to unified declarative JSON

- Consolidate all configuration toggles (suspend, idle, waybar, etc.) into ~/.config/home-manager/state.json
- Introduce nomarchy.toggles and nomarchy.hyprland options in Nix
- Inject toggle states into all bin/ scripts via environment variables
- Update toggle scripts to mutate JSON and trigger background rebuilds
- Add a migration script to transition legacy flag files to the new format
This commit is contained in:
Bernardo Magri
2026-04-04 10:11:09 +01:00
parent f1ed0d7f47
commit cfd5e4bb65
23 changed files with 378 additions and 173 deletions

View File

@@ -1,12 +1,29 @@
#!/bin/bash
#!/usr/bin/env bash
STATE_FILE=~/.local/state/nomarchy/toggles/suspend-off
# Toggles the suspend menu option availability.
# Hybrid: updates state.json and runs env-update for persistence.
if [[ -f $STATE_FILE ]]; then
rm -f $STATE_FILE
notify-send -u low "󰒲 Suspend now available in system menu"
STATE_FILE="$HOME/.config/home-manager/state.json"
mkdir -p "$(dirname "$STATE_FILE")"
# Initialize if doesn't exist
[[ ! -f $STATE_FILE ]] && echo "{}" > "$STATE_FILE"
# Get current state from env or state file
if [[ $NOMARCHY_TOGGLE_SUSPEND == "false" ]]; then
NEW_VALUE="true"
notify-send -u low "󰒲 Suspend now available in system menu"
else
mkdir -p "$(dirname $STATE_FILE)"
touch $STATE_FILE
notify-send -u low "󰒲 Suspend removed from system menu"
NEW_VALUE="false"
notify-send -u low "󰒲 Suspend removed from system menu"
fi
# Update JSON using jq
# We use a temporary file to avoid corruption if the shell is interrupted
TMP_JSON=$(mktemp)
jq ".suspend = $NEW_VALUE" "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
echo "Suspend availability set to $NEW_VALUE. Updating environment..."
# Run env-update to apply changes to the menu
env-update