summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/checkupdates
blob: 609a7621a1477ef5d730ae2dffab3518bd501cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
set -e

updates=$(pacman -Qu | sed '/\[ignored\]$/d')
COUNT=$(echo -n "${updates}" | wc -l)

ARG=${1:-$BLOCK_BUTTON}

case $ARG in
	1) if [ -n "${updates}" ]; then
			 notify-send -t $((1000 * 20)) "Available updates (${COUNT})" "$updates"
		else
			 notify-send "Available updates" "No available updates"
		fi;;
	3) doas /usr/bin/pacman -Sy;;
esac

[ -z "${updates}" ] && exit

[[ "${updates}" =~ .*linux.* ]] && echo -ne '\x0d' || echo -ne '\x0e'
[ "$COUNT" -gt 0 ] && echo -ne "$COUNT" || exit 0
echo -ne '\x0b'