mabox-colorizer/bin/checkupdates.sh

66 lines
1.8 KiB
Bash
Raw Normal View History

2022-05-19 14:50:08 +02:00
#!/bin/bash
# check updates and show how many packeges to update in Conky
# We don't need to run checkupdates at Conky start as it takes few seconds and block Conky
CNF_DIR="$HOME/.config/colorizer/conky"
CNF_FILE="$CNF_DIR/conky.cfg"
source <(grep = $CNF_FILE)
2022-05-20 13:45:52 +02:00
case "$LANG" in
pl*)
AVAIL_UPDATES="Dostępne aktualizacje"
UPTODATE="System jest aktualny"
PKGS_TO_UPDATE="Pakiety do aktualizacji:"
YAY_UPD="Użyj yay (cli)"
PAMAC_UPD="Użyj Pamac (GUI)"
DISABLE="Wyłącz powiadomienia"
;;
es*)
2022-05-24 19:32:53 +02:00
AVAIL_UPDATES="Actualizaciones disponibles"
UPTODATE="El sistema esta actualizado"
PKGS_TO_UPDATE="Paquetes para actualizar:"
YAY_UPD="Actualizar con yay (cli)"
PAMAC_UPD="Actualizar con Pamac (GUI)"
DISABLE="Deshabilitar notificaciones"
2022-05-20 13:45:52 +02:00
;;
*)
AVAIL_UPDATES="Available updates"
UPTODATE="System is up to date"
PKGS_TO_UPDATE="Packages to update:"
YAY_UPD="Update with yay (cli)"
PAMAC_UPD="Update with Pamac (GUI)"
DISABLE="Disable notifications"
;;
esac
2022-05-19 14:50:08 +02:00
case "$1" in
-s)
CONKYPID=$(pgrep -f sysinfo_mbcolor)
;;
-g)
CONKYPID=$(pgrep -f sysinfo_graph_mbcolor)
;;
*)
:
;;
esac
if [ -f /tmp/"$CONKYPID" ]; then
PKGS=$(pamac checkupdates -aq| wc -l)
if [ "$PKGS" != "0" ]; then
if [[ "$update_notifications" == "true" ]];then
2022-06-08 21:45:29 +02:00
notify-send.sh -t 30000 -i mbcc "$AVAIL_UPDATES" "$PKGS_TO_UPDATE $PKGS" -o "$YAY_UPD:terminator -T '$YAY_UPD' -e yay" \
2022-05-20 13:45:52 +02:00
-o "$PAMAC_UPD:pamac-manager --updates" -o "$DISABLE:mb-setvar update_notifications=false ${CNF_FILE}"
2022-05-19 14:50:08 +02:00
fi
2022-05-20 13:45:52 +02:00
printf "\${font}\${alignr} $AVAIL_UPDATES: \${color red}"
2022-05-19 14:50:08 +02:00
echo "$PKGS"
else
2022-05-20 13:45:52 +02:00
printf "\${font}\${color}\${alignr} $UPTODATE"
2022-05-19 14:50:08 +02:00
fi
else
echo "$SUM" > /tmp/${CONKYPID}
fi