#!/usr/bin/env bash # Three-state idle inhibitor for waybar (custom/inhibit): # off -> normal: swayidle active, wluma adjusting brightness # idle -> idle inhibited (idlehold running) # movie -> idle inhibited AND wluma stopped (brightness held steady) # Usage: inhibit.sh [status|cycle] SIGNAL=9 # idlehold: git.capella.pro/capella/idlehold (wlinhibit doesn't work on sway) IDLEHOLD="$HOME/.local/bin/idlehold" has_wluma() { systemctl --user cat wluma.service >/dev/null 2>&1; } inhibiting() { pgrep -x -u "$USER" idlehold >/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 "$IDLEHOLD" >/dev/null 2>&1; } inhibit_off() { pkill -x -u "$USER" idlehold; } 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