Last active
May 17, 2025 00:54
-
-
Save Dregu/ddba409a837ce87af8f9e26ef90f67e9 to your computer and use it in GitHub Desktop.
Control hyprsunset from waybar through IPC socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CMD=$1 | |
DELTA=$2 | |
TOGGLE=$3 | |
if [ -z "$CMD" ]; then | |
echo "Set or get gamma and color temperature through hyprsunset IPC socket" | |
echo "Usage: sunset.sh <gamma/temperature> [+-][value] [toggle]" | |
exit 1 | |
fi | |
if [[ ! -z "$TOGGLE" ]]; then | |
CUR=$(hyprctl hyprsunset $CMD) | |
FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%.0f" $CUR 2>/dev/null) | |
if [ "$FMT" = "$DELTA" ]; then | |
if [ "$CMD" = "gamma" ]; then | |
DELTA=100 | |
else | |
DELTA=6500 | |
fi | |
fi | |
fi | |
[ "$CMD" = "gamma" ] && LEN=3 || LEN=4 | |
if [[ ! -z "$DELTA" ]]; then | |
# rate limit and queue commands to workaround nvidia freezing on ctm spam | |
flock /tmp/sunset.lock sleep 0.1 | |
# tell waybar to update after a change | |
pkill -SIGRTMIN+$LEN waybar | |
fi | |
if NUM=$(hyprctl hyprsunset $CMD $DELTA); then | |
if FMT=$(LC_NUMERIC="en_US.UTF-8" printf "%$LEN.0f" $NUM 2>/dev/null); then | |
echo "$FMT" | |
fi | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
"custom/colortemp": { | |
"format": "<span size='12pt'>🌚</span> {}K", | |
"on-click": "~/.config/scripts/sunset.sh temperature 4000 toggle", | |
"on-click-right": "~/.config/scripts/sunset.sh temperature 6500", | |
"on-scroll-up": "~/.config/scripts/sunset.sh temperature +500", | |
"on-scroll-down": "~/.config/scripts/sunset.sh temperature -500", | |
"exec": "~/.config/scripts/sunset.sh temperature", | |
"exec-on-event": false, | |
"exec-if": "pidof hyprsunset", | |
"interval": "once", | |
"tooltip": false, | |
"signal": 4, | |
}, | |
"custom/gamma": { | |
"format": "<span size='12pt'>☀️</span> {}%", | |
"on-click": "~/.config/scripts/sunset.sh gamma 70 toggle", | |
"on-click-right": "~/.config/scripts/sunset.sh gamma 100", | |
"on-scroll-up": "~/.config/scripts/sunset.sh gamma +10", | |
"on-scroll-down": "~/.config/scripts/sunset.sh gamma -10", | |
"exec": "~/.config/scripts/sunset.sh gamma", | |
"exec-on-event": false, | |
"exec-if": "pidof hyprsunset", | |
"interval": "once", | |
"tooltip": false, | |
"signal": 3, | |
}, | |
}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment