Przeglądaj źródła

Sync: 2026-11-07 20:01:32

Gabriel Capella 3 dni temu
rodzic
commit
9ec59941dc

+ 8 - 9
dots/.config/waybar/config

@@ -34,7 +34,7 @@
         "memory",
         "cpu",
         "custom/keyboard-layout",
-        "idle_inhibitor",
+        "custom/inhibit",
         "tray",
 // @host jellyfish
         "custom/battery",
@@ -169,14 +169,13 @@
       "tooltip": true
     },
 
-    "idle_inhibitor": {
-        "format": "{icon}",
-        "format-icons": {
-            "activated": "",
-            "deactivated": ""
-        },
-        "tooltip-format-activated": "Idle inhibitor: ON",
-        "tooltip-format-deactivated": "Idle inhibitor: OFF"
+    // Click cycles: off -> idle inhibited -> movie (inhibited + wluma stopped).
+    "custom/inhibit": {
+        "exec": "~/.config/waybar/scripts/inhibit.sh status",
+        "return-type": "json",
+        "interval": 30,
+        "signal": 9,
+        "on-click": "~/.config/waybar/scripts/inhibit.sh cycle"
     },
 
     "tray": {

+ 55 - 0
dots/.config/waybar/scripts/inhibit.sh

@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Three-state idle inhibitor for waybar (custom/inhibit):
+#   off   -> normal: swayidle active, wluma adjusting brightness
+#   idle  -> idle inhibited (wlinhibit running)
+#   movie -> idle inhibited AND wluma stopped (brightness held steady)
+# Usage: inhibit.sh [status|cycle]
+
+SIGNAL=9
+
+has_wluma() { systemctl --user cat wluma.service >/dev/null 2>&1; }
+inhibiting() { pgrep -x -u "$USER" wlinhibit >/dev/null; }
+wluma_on() { systemctl --user -q is-active wluma.service; }
+
+state() {
+    if ! inhibiting; then
+        echo off
+    elif has_wluma && ! wluma_on; then
+        echo movie
+    else
+        echo idle
+    fi
+}
+
+inhibit_on() { inhibiting || setsid -f wlinhibit >/dev/null 2>&1; }
+inhibit_off() { pkill -x -u "$USER" wlinhibit; }
+
+case "${1:-status}" in
+    cycle)
+        case "$(state)" in
+            off)
+                inhibit_on
+                ;;
+            idle)
+                if has_wluma; then
+                    systemctl --user stop wluma.service
+                else
+                    inhibit_off
+                fi
+                ;;
+            movie)
+                inhibit_off
+                systemctl --user start wluma.service
+                ;;
+        esac
+        sleep 0.2
+        pkill -RTMIN+$SIGNAL waybar
+        ;;
+    status)
+        case "$(state)" in
+            off)   printf '{"text":"","alt":"off","class":"off","tooltip":"Idle inhibitor: OFF"}\n' ;;
+            idle)  printf '{"text":"","alt":"idle","class":"activated","tooltip":"Idle inhibitor: ON"}\n' ;;
+            movie) printf '{"text":"","alt":"movie","class":"movie","tooltip":"Movie mode: idle inhibited, wluma paused"}\n' ;;
+        esac
+        ;;
+esac

+ 5 - 5
dots/.config/waybar/style.css

@@ -61,7 +61,7 @@
 #cpu,
 #custom-brightness,
 #custom-keyboard-layout,
-#idle_inhibitor,
+#custom-inhibit,
 #memory,
 #mode,
 #network,
@@ -177,12 +177,12 @@
     color: red;
 }
 
-#idle_inhibitor {
-    /* No styles */
+#custom-inhibit.activated {
+    color: #dfc06e;
 }
 
-#idle_inhibitor.activated {
-    color: #dfc06e;
+#custom-inhibit.movie {
+    color: #e06c75;
 }
 
 #tray {

+ 2 - 0
pkglist

@@ -43,6 +43,7 @@ nmap
 noto-fonts-emoji
 ollama
 openssh
+otf-font-awesome
 otf-font-awesome-4
 pavucontrol
 pipewire
@@ -65,6 +66,7 @@ ttf-jetbrains-mono
 vim
 waybar
 wl-clipboard
+wlinhibit
 wluma
 woff2-font-awesome
 wtype