Add wallpaper, power, date, accessibility, and real search
Continues the settings expansion toward replacing GNOME Settings for everything Panama actually owns. Wallpaper. A thumbnail grid rather than a path field: the value of this setting is the picture, so typing a path to something you cannot see is the worst version of it. Two things about hyprpaper 0.8 shaped this. Its IPC is much smaller than older documentation suggests -- preload, listloaded, unload, and reload all answer "invalid hyprpaper request", so setting is a single call with no preload. And the "<empty>,<path>" form that used to mean every output is silently ignored, so a wallpaper set that way appears to succeed and never changes; outputs are walked explicitly instead. hyprpaper.conf lives in the repo through the ~/.config/hypr symlink and so cannot hold machine state, which is why the choice lives in the shared settings store and is re-applied at startup. Power & Lock. hypridle has no IPC for reconfiguration and its config is hyprlang rather than the shared JSON, so scripts/panama-idle generates a config from the settings store and restarts the daemon. The generated file lives under XDG_STATE_HOME for the same symlink reason, with a systemd drop-in pointing hypridle at it. Management is a real state and the page says which one you are in rather than showing sliders that quietly do nothing. Zero means never for all three timers, which a naive template would render as "immediately". Date & Time. Deliberately not stored in Panama's settings: the timezone and network time belong to the machine and are shared with sessions that never see this file. Storing a copy would create a second answer to a question the system already answers. Reads and writes timedatectl directly; a cancelled polkit prompt surfaces as an error rather than as a value that appears to have been accepted. Accessibility. Pointer size and text scale have to agree across three consumers with no shared configuration -- the compositor, GTK, and the shell -- so the store is the source of truth and the values are pushed outward to gsettings and hyprctl setcursor. Search now indexes the schema instead of the twelve page labels. "gaps", "wallpaper", and "screenshot" previously found nothing on an app that has all three, which is the clearest way a settings app feels smaller than it is. Shortcuts are indexed by what they do. A contract asserts every non-internal schema label is reachable, so a new setting cannot be added in an undiscoverable state. The GNOME delegation allow-list was widened to the panel names gnome-control-center actually reports; the previous list contained "users", which is not one of them and so opened nothing. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
Executable
+142
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generates hypridle's configuration from Panama's shared settings.
|
||||
#
|
||||
# Why this exists rather than editing hypridle.conf directly: ~/.config/hypr is
|
||||
# a symlink into the Panama repository, so writing hypridle.conf at runtime
|
||||
# would dirty a tracked file with machine state. The generated config therefore
|
||||
# lives under XDG_STATE_HOME, and a systemd drop-in points hypridle at it with
|
||||
# `-c`. The repository's hypridle.conf remains the shipped default and is what
|
||||
# runs if this has never been set up.
|
||||
#
|
||||
# panama-idle apply regenerate and restart hypridle
|
||||
# panama-idle status report as JSON what is in effect
|
||||
# panama-idle install write the systemd drop-in (idempotent)
|
||||
# panama-idle remove remove the drop-in and fall back to the shipped config
|
||||
#
|
||||
# All values are read from the settings store and clamped here as well as in the
|
||||
# schema, because this script is also reachable from a shell.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
settings="${XDG_CONFIG_HOME:-$HOME/.config}/panama/settings.json"
|
||||
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/panama"
|
||||
generated="$state_dir/hypridle.conf"
|
||||
dropin_dir="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/hypridle.service.d"
|
||||
dropin="$dropin_dir/panama.conf"
|
||||
|
||||
read_setting() {
|
||||
local key="$1" fallback="$2"
|
||||
[[ -r "$settings" ]] || { printf '%s' "$fallback"; return; }
|
||||
jq -r --arg k "$key" --arg d "$fallback" \
|
||||
'if has($k) and (.[$k] != null) then (.[$k] | tostring) else $d end' \
|
||||
"$settings" 2>/dev/null || printf '%s' "$fallback"
|
||||
}
|
||||
|
||||
clamp_int() {
|
||||
local value="$1" low="$2" high="$3" fallback="$4"
|
||||
[[ "$value" =~ ^-?[0-9]+$ ]] || { printf '%s' "$fallback"; return; }
|
||||
(( value < low )) && value="$low"
|
||||
(( value > high )) && value="$high"
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
load() {
|
||||
blank_min="$(clamp_int "$(read_setting screenBlankMinutes 5)" 0 120 5)"
|
||||
lock_min="$(clamp_int "$(read_setting lockMinutes 10)" 0 240 10)"
|
||||
suspend_min="$(clamp_int "$(read_setting suspendMinutes 0)" 0 480 0)"
|
||||
lock_on_sleep="$(read_setting lockOnSleep true)"
|
||||
[[ "$lock_on_sleep" == "true" || "$lock_on_sleep" == "false" ]] || lock_on_sleep=true
|
||||
}
|
||||
|
||||
generate() {
|
||||
load
|
||||
mkdir -p "$state_dir"
|
||||
|
||||
{
|
||||
printf '# Generated by panama-idle from %s\n' "$settings"
|
||||
printf '# Do not edit: it is rewritten whenever the idle settings change.\n'
|
||||
printf '# The shipped defaults live in the Panama repo at config/dot/hypr/hypridle.conf.\n\n'
|
||||
|
||||
printf 'general {\n'
|
||||
printf ' lock_cmd = pidof hyprlock || hyprlock\n'
|
||||
if [[ "$lock_on_sleep" == "true" ]]; then
|
||||
printf ' before_sleep_cmd = loginctl lock-session\n'
|
||||
fi
|
||||
printf " after_sleep_cmd = hyprctl dispatch 'hl.dsp.dpms({ action = \"on\" })'\n"
|
||||
printf ' inhibit_sleep = 2\n'
|
||||
printf '}\n'
|
||||
|
||||
if (( blank_min > 0 )); then
|
||||
printf '\n# %s minutes -> screen off.\n' "$blank_min"
|
||||
printf 'listener {\n'
|
||||
printf ' timeout = %s\n' "$(( blank_min * 60 ))"
|
||||
printf " on-timeout = hyprctl dispatch 'hl.dsp.dpms({ action = \"off\" })'\n"
|
||||
printf " on-resume = hyprctl dispatch 'hl.dsp.dpms({ action = \"on\" })'\n"
|
||||
printf '}\n'
|
||||
fi
|
||||
|
||||
if (( lock_min > 0 )); then
|
||||
printf '\n# %s minutes -> lock.\n' "$lock_min"
|
||||
printf 'listener {\n'
|
||||
printf ' timeout = %s\n' "$(( lock_min * 60 ))"
|
||||
printf ' on-timeout = loginctl lock-session\n'
|
||||
printf '}\n'
|
||||
fi
|
||||
|
||||
if (( suspend_min > 0 )); then
|
||||
printf '\n# %s minutes -> suspend.\n' "$suspend_min"
|
||||
printf 'listener {\n'
|
||||
printf ' timeout = %s\n' "$(( suspend_min * 60 ))"
|
||||
printf ' on-timeout = systemctl suspend\n'
|
||||
printf '}\n'
|
||||
fi
|
||||
} >"$generated.tmp"
|
||||
|
||||
mv "$generated.tmp" "$generated"
|
||||
}
|
||||
|
||||
install_dropin() {
|
||||
mkdir -p "$dropin_dir"
|
||||
cat >"$dropin" <<EOF
|
||||
# Installed by panama-idle. Points hypridle at the configuration Panama
|
||||
# generates from its settings store, so idle timings are adjustable from
|
||||
# Panama Settings rather than by editing a file in the Panama repository.
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/hypridle -c $generated
|
||||
EOF
|
||||
systemctl --user daemon-reload
|
||||
}
|
||||
|
||||
case "${1:-apply}" in
|
||||
apply)
|
||||
generate
|
||||
if [[ -f "$dropin" ]]; then
|
||||
systemctl --user restart hypridle.service
|
||||
fi
|
||||
;;
|
||||
install)
|
||||
generate
|
||||
install_dropin
|
||||
systemctl --user restart hypridle.service
|
||||
;;
|
||||
remove)
|
||||
rm -f "$dropin"
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user restart hypridle.service
|
||||
;;
|
||||
status)
|
||||
load
|
||||
managed=false
|
||||
[[ -f "$dropin" ]] && managed=true
|
||||
printf '{"managed":%s,"active":"%s","blankMinutes":%s,"lockMinutes":%s,"suspendMinutes":%s,"lockOnSleep":%s,"generated":"%s"}\n' \
|
||||
"$managed" \
|
||||
"$(systemctl --user is-active hypridle.service 2>/dev/null || printf unknown)" \
|
||||
"$blank_min" "$lock_min" "$suspend_min" "$lock_on_sleep" "$generated"
|
||||
;;
|
||||
*)
|
||||
printf 'usage: panama-idle [apply|install|remove|status]\n' >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user