dotfiles/.i3blocks/updates

36 lines
946 B
Plaintext
Raw Normal View History

2018-11-30 22:00:19 +01:00
#!/bin/bash
2020-01-09 21:17:01 +01:00
runtime="${XDG_RUNTIME_DIR}/i3blocks"
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"
2019-09-09 20:04:37 +02:00
echo -n "updt "
2020-01-09 21:17:01 +01:00
if [[ -f ${runtime}/claws_offline ]]
then
2019-07-19 23:11:53 +02:00
echo "<span foreground=\"#F2777A\">█</span>"
exit
fi
2020-01-09 21:17:01 +01:00
if [[ ! -f ${runtime}/updates ]]
then
2020-01-09 21:17:01 +01:00
echo 0 > ${runtime}/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-07-19 23:11:53 +02:00
echo "<span foreground=\"#99CC99\">█</span>"
else
2019-07-19 23:11:53 +02:00
echo "<span foreground=\"#FFCC66\">█</span>"
2020-01-09 21:17:01 +01:00
if [[ $(cat ${runtime}/updates) -ne $total ]] || [[ -n "$BLOCK_BUTTON" ]]
then
2019-04-19 22:18:25 +02:00
[[ $total -eq 1 ]] && notify-send "1 mise à jour disponible" "$(for item in ${avail[@]} ${aur[@]}; do echo -n $item; done)"
[[ $total -gt 1 ]] && notify-send "$total mises à jour disponibles" "$(for item in ${avail[@]} ${aur[@]}; do echo -n "$item, "; done | sed 's/, $//g')"
fi
fi
2020-01-09 21:17:01 +01:00
echo $total > ${runtime}/updates