fix(caffeine): set DISPLAY, check DPMS state

Amolith created

Change summary

dot_local/bin/executable_caffeine | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Detailed changes

dot_local/bin/executable_caffeine 🔗

@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+export DISPLAY="${DISPLAY:-:0}"
+
 STATE_FILE="$XDG_CACHE_HOME/caffeine_state"
 PID_FILE="$XDG_CACHE_HOME/caffeine.pid"
 
@@ -23,12 +25,12 @@ toggle)
             sleep infinity &
         echo $! >"$PID_FILE"
         touch "$STATE_FILE"
-        xset -dpms s off s noblank
+        xset -dpms s off
         notify-send "Caffeine on" "System will stay awake."
     fi
     ;;
 status)
-    if [ -n "$(caffeine_pid)" ]; then
+    if xset q 2>/dev/null | grep -q "DPMS is Disabled"; then
         echo "󰅶"
     else
         echo "󰾪"