dotfiles/.i3blocks/updates

30 lines
669 B
Bash
Executable file

#!/usr/bin/env bash
if [ -f /dev/shm/claws_offline ]
then
echo "<span foreground=\"#F2777A\">█</span>"
exit
fi
if [ ! -f /dev/shm/updates ]
then
echo 0 > /dev/shm/updates
fi
avail=$(checkupdates | wc -l)
aur=$(yaourt -Qua | grep 'aur/' | wc -l)
total=$(($avail + $aur))
if [[ $total -eq 0 ]]
then
echo "<span foreground=\"#99CC99\">█</span>"
else
echo "<span foreground=\"#FFCC66\">█</span>"
if [[ $(cat /dev/shm/updates) -ne $total ]]
then
[[ $total -eq 1 ]] && notify-send "Mise à jour disponible" "1 màj disponible"
[[ $total -gt 1 ]] && notify-send "Mises à jour disponibles" "$total màj disponibles"
fi
fi
echo $total > /dev/shm/updates