dotfiles/.i3blocks/updates

31 lines
808 B
Text
Raw Normal View History

2018-11-30 22:00:19 +01:00
#!/bin/bash
2018-11-30 22:00:19 +01:00
if [[ -f /dev/shm/claws_offline ]]
then
2019-01-21 08:16:41 +01:00
echo "<span foreground=\"#F2777A\">▣</span>"
exit
fi
2018-11-30 22:00:19 +01:00
if [[ ! -f /dev/shm/updates ]]
then
echo 0 > /dev/shm/updates
fi
2018-11-30 22:00:19 +01:00
avail=($(checkupdates | cut -d' ' -f1))
aur=($(yaourt -Qua | cut -d' ' -f1 | grep 'aur/'))
total=$((${#avail[@]} + ${#aur[@]}))
if [[ $total -eq 0 ]]
then
2019-01-21 08:16:41 +01:00
echo "<span foreground=\"#99CC99\">▣</span>"
else
2019-01-21 08:16:41 +01:00
echo "<span foreground=\"#FFCC66\">▣</span>"
2018-11-30 22:00:19 +01:00
if [[ $(cat /dev/shm/updates) -ne $total ]] || [[ -n "$BLOCK_BUTTON" ]]
then
2018-11-30 22:00:19 +01:00
[[ $total -eq 1 ]] && notify-send "1 mise à jour disponible" "$(for item in ${avail[@]} ${aur[@]}; do echo $item; done)"
[[ $total -gt 1 ]] && notify-send "$total mises à jour disponibles" "$(for item in ${avail[@]} ${aur[@]}; do echo $item; done)"
fi
fi
echo $total > /dev/shm/updates