dotfiles/.i3blocks/updates
2024-02-08 12:09:26 +01:00

33 lines
944 B
Bash
Executable file

#!/bin/bash
runtime="${XDG_RUNTIME_DIR}/i3blocks"
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"
if [[ -f ${runtime}/claws_offline ]]
then
echo "<span foreground=\"#F2777A\">màj</span>"
exit
fi
if [[ ! -f ${runtime}/updates ]]
then
echo 0 > ${runtime}/updates
fi
avail=($(checkupdates --nocolor | cut -d' ' -f1))
aur=($(pikaur -Qua | cut -d' ' -f2))
total=$((${#avail[@]} + ${#aur[@]}))
if [[ $total -eq 0 ]]
then
echo "<span foreground=\"#99CC99\">màj</span>"
else
echo "<span foreground=\"#FFCC66\">màj</span>"
if [[ $(cat ${runtime}/updates) -lt $total ]] || [[ -n "$BLOCK_BUTTON" ]]
then
[[ $total -eq 1 ]] && dunstify -r "57453" "1 mise à jour disponible" "$(for item in ${avail[@]} ${aur[@]}; do echo -n $item; done)"
[[ $total -gt 1 ]] && dunstify -r "57453" "$total mises à jour disponibles" "$(for item in ${avail[@]} ${aur[@]}; do echo -n "$item, "; done | sed 's/, $//g')"
fi
fi
echo $total > ${runtime}/updates