2018-11-30 22:00:19 +01:00
|
|
|
#!/bin/bash
|
2017-11-22 01:27:01 +01:00
|
|
|
|
2020-01-09 21:17:01 +01:00
|
|
|
runtime="${XDG_RUNTIME_DIR}/i3blocks"
|
|
|
|
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"
|
|
|
|
|
|
|
|
if [[ -f ${runtime}/claws_offline ]]
|
2018-03-06 14:47:28 +01:00
|
|
|
then
|
2020-12-31 11:14:20 +01:00
|
|
|
echo "<span foreground=\"#F2777A\">màj</span>"
|
2018-03-06 14:47:28 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2020-01-09 21:17:01 +01:00
|
|
|
if [[ ! -f ${runtime}/updates ]]
|
2018-06-02 00:09:39 +02:00
|
|
|
then
|
2020-01-09 21:17:01 +01:00
|
|
|
echo 0 > ${runtime}/updates
|
2018-06-02 00:09:39 +02:00
|
|
|
fi
|
|
|
|
|
2024-02-08 12:09:26 +01:00
|
|
|
avail=($(checkupdates --nocolor | cut -d' ' -f1))
|
2020-10-21 01:12:08 +02:00
|
|
|
aur=($(pikaur -Qua | cut -d' ' -f2))
|
2018-11-30 22:00:19 +01:00
|
|
|
total=$((${#avail[@]} + ${#aur[@]}))
|
2017-11-22 01:27:01 +01:00
|
|
|
|
2018-06-02 00:09:39 +02:00
|
|
|
if [[ $total -eq 0 ]]
|
2017-11-22 01:27:01 +01:00
|
|
|
then
|
2020-12-31 11:14:20 +01:00
|
|
|
echo "<span foreground=\"#99CC99\">màj</span>"
|
2017-11-22 01:27:01 +01:00
|
|
|
else
|
2020-12-31 11:14:20 +01:00
|
|
|
echo "<span foreground=\"#FFCC66\">màj</span>"
|
2020-04-18 01:44:01 +02:00
|
|
|
if [[ $(cat ${runtime}/updates) -lt $total ]] || [[ -n "$BLOCK_BUTTON" ]]
|
2018-06-02 00:09:39 +02:00
|
|
|
then
|
2020-05-17 20:29:45 +02:00
|
|
|
[[ $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')"
|
2018-06-02 00:09:39 +02:00
|
|
|
fi
|
2017-11-22 01:27:01 +01:00
|
|
|
fi
|
2018-06-02 00:09:39 +02:00
|
|
|
|
2020-01-09 21:17:01 +01:00
|
|
|
echo $total > ${runtime}/updates
|