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:
@@ -1,7 +1,25 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if pgrep -x waybar >/dev/null; then
|
||||
pkill -x waybar
|
||||
# Toggles the waybar top bar.
|
||||
# Hybrid: updates state.json and provides instant feedback.
|
||||
|
||||
STATE_FILE="$HOME/.config/home-manager/state.json"
|
||||
mkdir -p "$(dirname "$STATE_FILE")"
|
||||
|
||||
# Initialize if doesn't exist
|
||||
[[ ! -f $STATE_FILE ]] && echo "{}" > "$STATE_FILE"
|
||||
|
||||
if [[ $NOMARCHY_TOGGLE_WAYBAR == "false" ]]; then
|
||||
NEW_VALUE="true"
|
||||
uwsm-app -- waybar >/dev/null 2>&1 &
|
||||
notify-send -u low " Top bar enabled"
|
||||
else
|
||||
uwsm-app -- waybar >/dev/null 2>&1 &
|
||||
NEW_VALUE="false"
|
||||
pkill -x waybar
|
||||
notify-send -u low " Top bar disabled"
|
||||
fi
|
||||
|
||||
TMP_JSON=$(mktemp)
|
||||
jq ".waybar = $NEW_VALUE" "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
|
||||
|
||||
echo "Waybar state set to $NEW_VALUE. Environment will be fully updated on next rebuild."
|
||||
|
||||
Reference in New Issue
Block a user