Refactor toggles and notifications

This commit is contained in:
David Heinemeier Hansson
2026-05-10 11:26:59 +02:00
parent d3a082ef11
commit 26c1f9c546
7 changed files with 126 additions and 80 deletions
+36 -23
View File
@@ -1,32 +1,45 @@
#!/bin/bash
# omarchy:summary=Toggle permanent Hyprland flags by copying them into a directory that's sourced entirely.
# omarchy:args=[--enabled-notification <text>] [--disabled-notification <text>] <flag-name>
ENABLED_NOTIFICATION=""
DISABLED_NOTIFICATION=""
while [[ $# -gt 1 ]]; do
case $1 in
--enabled-notification) ENABLED_NOTIFICATION="$2"; shift 2 ;;
--disabled-notification) DISABLED_NOTIFICATION="$2"; shift 2 ;;
*) break ;;
esac
done
# omarchy:args=<flag-name> [on|off]
FLAG_NAME="$1"
ACTION="${2:-toggle}"
FLAG="$HOME/.local/state/omarchy/toggles/hypr/$FLAG_NAME.conf"
FLAG_SOURCE="$OMARCHY_PATH/default/hypr/toggles/$FLAG_NAME.conf"
if [[ -f $FLAG ]]; then
rm $FLAG
[[ -n $DISABLED_NOTIFICATION ]] && notify-send -u low "$DISABLED_NOTIFICATION"
elif [[ -f $FLAG_SOURCE ]]; then
cp $FLAG_SOURCE $FLAG
[[ -n $ENABLED_NOTIFICATION ]] && notify-send -u low "$ENABLED_NOTIFICATION"
else
echo "Flag not found: $FLAG_NAME"
exit 1
fi
on() {
if [[ -f $FLAG_SOURCE ]]; then
mkdir -p "$(dirname "$FLAG")"
cp "$FLAG_SOURCE" "$FLAG"
echo "on"
else
echo "Flag not found: $FLAG_NAME"
exit 1
fi
}
hyprctl reload
off() {
rm -f "$FLAG"
echo "off"
}
toggle() {
if [[ -f $FLAG ]]; then
off
else
on
fi
}
case $ACTION in
on) on ;;
off) off ;;
toggle) toggle ;;
*)
echo "Usage: omarchy-hyprland-toggle <flag-name> [on|off]"
exit 1
;;
esac
hyprctl reload >/dev/null