#!/bin/bash
#
# This script has to be used in an XFCE4 generic monitor plugin
# https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin
#
# it is necessary to schedule a regular check of update with root account
# add this line in root crontab (without first #) executed each 2 hours
# */2 * * * * /usr/bin/pacman -Sy >/dev/null 2>&1
#
# count lines of updates
NB_PACKAGES=$(checkupdates | wc -l)
# display OK icon or number of updates
if [ $NB_PACKAGES -eq 0 ];then
echo "/usr/share/icons/Adwaita/24x24/legacy/emblem-default.png"
else
echo "$NB_PACKAGES upd "
echo "/usr/share/icons/Adwaita/24x24/legacy/system-software-update.png"
fi
# generate tooltip with list of packages to update
echo "$(checkupdates)"
# on click, lauch "pacman -Syu" in a terminal
echo "xfce4-terminal -H -e 'zsh -c \"sudo pacman -Syu \"'"
# end