-
Notifications
You must be signed in to change notification settings - Fork 0
/
polybar_services.sh
executable file
·65 lines (58 loc) · 1.71 KB
/
polybar_services.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# path: /home/klassiker/.local/share/repos/polybar/polybar_services.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/polybar
# date: 2024-12-18T07:53:32+0100
# speed up script by using standard c
LC_ALL=C
LANG=C
# source polybar helper
. _polybar_helper.sh
set_output() {
if [ -z "$services" ]; then
services="$(printf "%s" "$1")"
else
services="$(printf "%s %s" "$services" "$1")"
fi
}
service_status() {
case "$3" in
wireguard)
[ "$(wireguard_toggle.sh -s "$1")" = "$1 is enabled" ] \
&& set_output "$2"
;;
user)
systemctl --user -q is-active "$1" \
&& set_output "$2"
;;
*)
systemctl -q is-active "$1" \
&& set_output "$2"
;;
esac
}
case "$1" in
--status)
service_status "xautolock.service" "" "user"
service_status "i3_autotiling.service" "" "user"
service_status "picom.service" "" "user"
service_status "wacom.service" "" "user"
service_status "xbanish.service" "" "user"
service_status "systemd-resolved.service" ""
service_status "systemd-timesyncd.service" ""
service_status "sshd.service" ""
service_status "wg0" "" "wireguard"
service_status "cups.service" ""
service_status "bluetooth.service" ""
polybar_output "%{T2}$services%{T-} "
;;
--update)
for id in $(pgrep -f "polybar main"); do
polybar-msg -p "$id" \
action "#services.hook.0" >/dev/null 2>&1 &
done
;;
*)
i3_services.sh
;;
esac