dotfiles/.i3blocks/updates

36 lines
946 B
Bash
Executable File

#!/bin/bash
runtime="${XDG_RUNTIME_DIR}/i3blocks"
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"
echo -n "updt "
if [[ -f ${runtime}/claws_offline ]]
then
echo "<span foreground=\"#F2777A\">█</span>"
exit
fi
if [[ ! -f ${runtime}/updates ]]
then
echo 0 > ${runtime}/updates
fi
avail=($(checkupdates | cut -d' ' -f1))
aur=($(yaourt -Qua | cut -d' ' -f1 | grep 'aur/'))
total=$((${#avail[@]} + ${#aur[@]}))
if [[ $total -eq 0 ]]
then
echo "<span foreground=\"#99CC99\">█</span>"
else
echo "<span foreground=\"#FFCC66\">█</span>"
if [[ $(cat ${runtime}/updates) -ne $total ]] || [[ -n "$BLOCK_BUTTON" ]]
then
[[ $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
echo $total > ${runtime}/updates