diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-02-20 14:22:13 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-02-20 14:37:12 +0100 |
| commit | 018fdcb5a16b7a984a38c78d8715f5e05bad3137 (patch) | |
| tree | 9f72971e826bf97c4435ce9261a930cb5f0d00bb /roles/hyprland/files/scripts | |
| parent | 37e2f822c37e4ce08b029595c04e692eb197f86e (diff) | |
Add hyprland sunset and hyprpicker with scripts/waybar integration
Diffstat (limited to 'roles/hyprland/files/scripts')
| -rwxr-xr-x | roles/hyprland/files/scripts/sunset.sh | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/roles/hyprland/files/scripts/sunset.sh b/roles/hyprland/files/scripts/sunset.sh new file mode 100755 index 00000000..52f3ea7c --- /dev/null +++ b/roles/hyprland/files/scripts/sunset.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# Default temperature values +TEMP_ON=4000 +TEMP_OFF=6000 + +get_temp() { + local temp="$(hyprctl hyprsunset temperature 2>/dev/null | grep -oE '[0-9]+')" + echo "$temp" +} + +get_status() { + read -r temp <<< "$(get_temp)" + local waybar_status="" + if [[ "$temp" == "$TEMP_ON" ]]; then + waybar_status=$(printf '{"alt": "on", "tooltip": "Nightshift On (temp: %s)"}' "$temp") + else + waybar_status=$(printf '{"alt": "off", "tooltip": "Nightshift Off (temp: %s)"}' "$temp") + fi + echo "${waybar_status}" +} + +set_temp() { + local temp=$1 + hyprctl hyprsunset temperature $temp 2>/dev/null 1>&2 + notify "" "" "$TEMP" + pkill -x -SIGRTMIN+6 waybar +} + +toggle_nightshift() { + read -r temp <<< "$(get_temp)" + if [[ "$temp" == "$TEMP_ON" ]]; then + set_temp $TEMP_OFF + temp=$TEMP_OFF + class="off" + icon="" + else + set_temp $TEMP_ON + temp=$TEMP_ON + class="on" + icon="" + fi + notify "$class" "$icon" "$temp" + pkill -x -SIGRTMIN+6 waybar +} + +notify() { + local class="$1" + local icon="$2" + local temp="$3" + notify-send -e \ + -h string:x-canonical-private-synchronous:sunset \ + -u low \ + "${icon} Nightshift ${class}" \ + "Temprature: ${temp}" +} + +TEMP="${2:-$TEMP_ON}" +case "$1" in + "--get") + read -r temp <<< "$(get_temp)" + echo "${temp}" + ;; + "--set") + set_temp "$TEMP" + ;; + "--status") + get_status + ;; + "--toggle") + toggle_nightshift + ;; + *) + echo -e "Usage:" + echo -e " --get to get current screen temprature value" + echo -e " --set [arg] to set current screen temprature to [arg]" + echo -e " --toggle to toggle sunset/nightshift" + echo -e " --staus to get the (waybar) JSON staus" + exit 0 + ;; +esac |
