blob: 05c4a8c2d562a232bb2366a97b0328bc1b760d00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env bash
# Presentation mode: keep the screen awake, and say so with a themed icon.
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
# Licensed under the GNU General Public License v2 only.
#
# waybar's own idle_inhibitor module draws its state with format-icons, which
# is text. This drives the same idea through hypridle and reports the state as
# an icon path for an `image` module instead.
#
# wb-idle status # print "$path\n$tooltip" for the image module
# wb-idle toggle # flip the inhibitor, then refresh the module
#
# The inhibitor is hypridle's own pause, so nothing else has to be running.
set -euo pipefail
state_file="${XDG_RUNTIME_DIR:-/tmp}/wb-idle.state"
active() { [[ -f "$state_file" ]]; }
case "${1:-status}" in
toggle)
if active; then
rm -f "$state_file"
# Resume idling. Guarded: hypridle may not be running, and that is
# not an error worth failing a click over.
pkill -USR2 -x hypridle 2>/dev/null || true
else
touch "$state_file"
pkill -USR1 -x hypridle 2>/dev/null || true
fi
# Refresh the module now rather than waiting for its interval.
pkill -RTMIN+9 -x waybar 2>/dev/null || true
;;
status)
if active; then
wb-icon idle activated
else
wb-icon idle deactivated
fi
;;
*)
echo "usage: wb-idle <status|toggle>" >&2
exit 2
;;
esac
|