diff --git a/hypr/scripts/idle-inhibit-toggle.sh b/hypr/scripts/idle-inhibit-toggle.sh new file mode 100755 index 0000000..fbebdbf --- /dev/null +++ b/hypr/scripts/idle-inhibit-toggle.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +PIDFILE="$XDG_RUNTIME_DIR/idle-inhibit.pid" + +if [[ -f "$PIDFILE" ]] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then + kill "$(cat "$PIDFILE")" + rm -f "$PIDFILE" + echo "off" +else + systemd-inhibit --what=idle:sleep --why="Manual Waybar inhibit" sleep infinity & + echo $! > "$PIDFILE" + echo "on" +fi diff --git a/waybar/config b/waybar/config index 7b6c580..6fdc45f 100644 --- a/waybar/config +++ b/waybar/config @@ -15,6 +15,7 @@ "network", "hyprland/language", "custom/notifications", + "custom/idle-inhibit", "custom/power" ], @@ -100,6 +101,15 @@ "escape": true }, + "custom/idle-inhibit": { + "exec": "if test -f $XDG_RUNTIME_DIR/idle-inhibit.pid; then echo '󰅶'; else echo '󰾪'; fi", + "on-click": "~/.config/hypr/scripts/idle-inhibit-toggle.sh", + "interval": 2, + "return-type": "raw", + "tooltip": true, + "tooltip-format": "Idle inhibit" + }, + "custom/power": { "format": " ⏻ ", "tooltip": false, diff --git a/waybar/style.css b/waybar/style.css index 9455541..875f8b3 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -81,7 +81,8 @@ window#waybar { #window, #custom-power, #language, -#mpd { +#mpd, +#custom-idle-inhibit { margin: 8px 2px; padding: 0 18px 0 18px; color: black;