mabox-colorizer/bin/checkupdates.sh

68 lines
1.9 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)
2024-02-22 14:24:51 +01:00
PKGS=$(checkupdates | wc -l)
mb-setvar updates=${PKGS}
2022-05-19 14:50:08 +02:00
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)
;;
2022-12-08 17:48:55 +01:00
-m)
CONKYPID=$(pgrep -f mabox_info_mbcolor)
2022-05-19 14:50:08 +02:00
;;
esac
if [ -f /tmp/"$CONKYPID" ]; then
2024-02-22 14:24:51 +01:00
PKGS=$(checkupdates | wc -l)
2022-05-19 14:50:08 +02:00
if [ "$PKGS" != "0" ]; then
if [[ "$update_notifications" == "true" ]];then
2022-09-21 00:27:41 +02:00
notify-send.sh -u critical -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
2023-01-08 02:26:59 +01:00
echo "$1" > /tmp/"${CONKYPID}"
2022-05-19 14:50:08 +02:00
fi