summaryrefslogtreecommitdiffstats
path: root/roles/hyprland
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-02-20 14:22:13 +0100
committerAhmed Abdelhalim <[email protected]>2026-02-20 14:37:12 +0100
commit018fdcb5a16b7a984a38c78d8715f5e05bad3137 (patch)
tree9f72971e826bf97c4435ce9261a930cb5f0d00bb /roles/hyprland
parent37e2f822c37e4ce08b029595c04e692eb197f86e (diff)
Add hyprland sunset and hyprpicker with scripts/waybar integration
Diffstat (limited to 'roles/hyprland')
-rwxr-xr-xroles/hyprland/files/scripts/sunset.sh81
-rw-r--r--roles/hyprland/tasks/main.yml4
-rw-r--r--roles/hyprland/templates/autostart.conf.j21
3 files changed, 86 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
diff --git a/roles/hyprland/tasks/main.yml b/roles/hyprland/tasks/main.yml
index 180d12da..61a693bf 100644
--- a/roles/hyprland/tasks/main.yml
+++ b/roles/hyprland/tasks/main.yml
@@ -8,6 +8,8 @@
- "swaybg"
- "hyprlock"
- "hypridle"
+ - "hyprpicker"
+ - "hyprsunset"
- "hyprland"
- "xdg-desktop-portal-gtk"
- "xdg-desktop-portal-hyprland"
@@ -102,3 +104,5 @@
dest: "/etc/hypr/scripts/brightness.sh"
- src: "scripts/volume.sh"
dest: "/etc/hypr/scripts/volume.sh"
+ - src: "scripts/sunset.sh"
+ dest: "/etc/hypr/scripts/sunset.sh"
diff --git a/roles/hyprland/templates/autostart.conf.j2 b/roles/hyprland/templates/autostart.conf.j2
index d110a6bd..36ecf73c 100644
--- a/roles/hyprland/templates/autostart.conf.j2
+++ b/roles/hyprland/templates/autostart.conf.j2
@@ -5,3 +5,4 @@ exec-once = uwsm-app -- mako
exec-once = uwsm-app -- waybar
exec-once = uwsm-app -- swaybg -i ~/.config/hyprtheme/current/background -m fill
exec-once = uwsm-app -- clipse -listen
+exec-once = uwsm app -- hyprsunset