summaryrefslogtreecommitdiff
path: root/scripts/nightlight-toggle
blob: 7e093037149c97eb4714b17c14da87243427a443 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash

hyprland_nightlight_toggle() {
  # Default temperature values
  ON_TEMP=4500
  OFF_TEMP=6000
  # Ensure hyprsunset is running
  if ! pgrep -x hyprsunset; then
    hyprsunset &
    sleep 1 # Give it time to register
  fi
  # Query the current temperature
  CURRENT_TEMP=$(hyprctl hyprsunset temperature 2>/dev/null | grep -oE '[0-9]+')
  if [[ "$CURRENT_TEMP" == "$OFF_TEMP" ]]; then
    hyprctl hyprsunset temperature $ON_TEMP
    notify-send " Nightlight screen temperature"
  else
    hyprctl hyprsunset temperature $OFF_TEMP
    notify-send " Daylight screen temperature"
  fi
}

niri_nightlight_toggle() {
  if pgrep -x wlsunset; then
    killall wlsunset
    notify-send " Daylight screen temperature"
  else
    setsid -f wlsunset -T 4500
    notify-send " Nightlight screen temperature"
  fi
}

case "$1" in
*niri)
  niri_nightlight_toggle
  ;;
*hyprland)
  hyprland_nightlight_toggle
  ;;
esac