-
Notifications
You must be signed in to change notification settings - Fork 0
/
polybar_pacman.sh
executable file
·52 lines (43 loc) · 1.36 KB
/
polybar_pacman.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
#!/bin/sh
# path: /home/klassiker/.local/share/repos/polybar/polybar_pacman.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/polybar
# date: 2024-12-18T07:53:26+0100
# use standard c to identify paru ignored updates
LC_ALL=C
LANG=C
# source polybar helper
. _polybar_helper.sh
get_pacman_mirror() {
grep '^Server' /etc/pacman.d/mirrorlist \
| head -n1 \
| cut -d'/' -f3
}
case "$1" in
--update)
for id in $(pgrep -f "polybar main"); do
polybar-msg -p "$id" \
action "#packages.hook.0" >/dev/null 2>&1 &
done
;;
*)
polybar_net_check "$(get_pacman_mirror)" \
|| exit 1
updates_pacman=$(checkupdates --nocolor 2> /dev/null | wc -l)
updates_aur=$(paru -Qua | grep -c -v "\[ignored\]" 2> /dev/null)
icon_pacman="%{T2} %{T-}"
icon_aur="%{T2} %{T-}"
if [ "$updates_pacman" -gt 0 ] \
&& [ "$updates_aur" -gt 0 ]; then \
polybar_output \
"$icon_pacman$updates_pacman $icon_aur$updates_aur"
else
[ "$updates_pacman" -gt 0 ] \
&& polybar_output \
"$icon_pacman$updates_pacman"
[ "$updates_aur" -gt 0 ] \
&& polybar_output \
"$icon_aur$updates_aur"
fi
;;
esac