nirish

config files for niri window manager
Log | Files | Refs | README | LICENSE

nightlight-toggle (919B)


      1 #!/usr/bin/env bash
      2 
      3 hyprland_nightlight_toggle() {
      4   # Default temperature values
      5   ON_TEMP=4500
      6   OFF_TEMP=6000
      7   # Ensure hyprsunset is running
      8   if ! pgrep -x hyprsunset; then
      9     hyprsunset &
     10     sleep 1 # Give it time to register
     11   fi
     12   # Query the current temperature
     13   CURRENT_TEMP=$(hyprctl hyprsunset temperature 2>/dev/null | grep -oE '[0-9]+')
     14   if [[ "$CURRENT_TEMP" == "$OFF_TEMP" ]]; then
     15     hyprctl hyprsunset temperature $ON_TEMP
     16     notify-send "Nightlight screen temperature"
     17   else
     18     hyprctl hyprsunset temperature $OFF_TEMP
     19     notify-send "Daylight screen temperature"
     20   fi
     21 }
     22 
     23 niri_nightlight_toggle() {
     24   if pgrep -x wlsunset; then
     25     killall wlsunset
     26     notify-send "Daylight screen temperature"
     27   else
     28     setsid -f wlsunset -T 4500
     29     notify-send "Nightlight screen temperature"
     30   fi
     31 }
     32 
     33 case "$1" in
     34 *niri)
     35   niri_nightlight_toggle
     36   ;;
     37 *hyprland)
     38   hyprland_nightlight_toggle
     39   ;;
     40 esac