#!/bin/zsh ICON=/usr/share/icons/Papirus/24x24/panel/software-update-available.png IDCACHE=${XDG_CACHE_HOME:-$HOME/.cache}/xcheckupdates-id zparseopts -D -E l=list -list=list if [[ -e $IDCACHE ]]; then prev_id=$(<$IDCACHE) fi sudo xbps-install -S &>/dev/null updates=$(xbps-install -un 2>&1) num_updates=$(echo $updates | wc -l) if [[ $list ]]; then echo -n $updates fi if [[ $num_updates -gt 0 ]]; then notify-send -p ${prev_id+-r} $prev_id --icon=$ICON -t 0 "$num_updates Updates available $(echo; awk '{ print " -",$1 }' <<<$updates | head -n 10; if [[ $num_updates -gt 10 ]]; then echo " ..."; fi)" else notify-send -p ${prev_id+-r} $prev_id -t 1500 "Updates checked, nothing new" fi > $IDCACHE