2022-04-19 04:37:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ "$1" == 'bar' ]; then
|
|
|
|
if [ ! -e ${HOME}/.spool/apt-upgradeable ]; then
|
|
|
|
sudo apt update >/dev/null 2>/dev/null
|
|
|
|
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
|
|
|
|
let COUNT--
|
|
|
|
echo $COUNT > /home/jpm/.spool/apt-upgradeable
|
|
|
|
else
|
|
|
|
COUNT=`cat ${HOME}/.spool/apt-upgradeable`
|
|
|
|
fi
|
|
|
|
if [ $COUNT -eq 0 ]; then
|
|
|
|
echo '{"text": "🗹", "tooltip": "Up-to-date", "class": "up-to-date"}'
|
|
|
|
else
|
2022-05-26 16:08:29 +00:00
|
|
|
echo '{"text": "⭳'$COUNT'", "tooltip": "'$COUNT' updates available (click to download)", "class": "updateable"}'
|
2022-04-19 04:37:30 +00:00
|
|
|
fi
|
|
|
|
elif [ "$SUDO_USER" != '' ]; then
|
|
|
|
echo "Don't run with sudo. Run normally, but with a sudoer user"
|
|
|
|
elif [ $UID -eq 0 ]; then
|
|
|
|
echo "Don't run as root. Run normally, but with a sudoer user"
|
|
|
|
elif [ "$1" == 'upgrade' ]; then
|
|
|
|
/usr/bin/uxterm -e "sudo apt-get update && sudo apt-get full-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean -y && exit"
|
|
|
|
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
|
|
|
|
let COUNT--
|
|
|
|
echo $COUNT > /home/jpm/.spool/apt-upgradeable
|
2022-07-21 03:11:59 +00:00
|
|
|
if [ -e /var/run/reboot-required ]; then
|
|
|
|
cat /var/log/apt/history.log | tr "\n" "%" | sed -e 's/.*\(Start-Date\)/\1/g' | tr "%" "\n" | swaynag --config=${HOME}/.dotfiles/sway/swaynag --edge=bottom --message="New packages require restart" --button="Restart Now" "sudo systemctl reboot" --dismiss-button="Later" --detailed-message --detailed-button "Show/Hide Upgrade Details"
|
|
|
|
fi
|
2022-04-19 04:37:30 +00:00
|
|
|
elif [ "$1" == 'update' ]; then
|
|
|
|
sudo apt update >/dev/null 2>/dev/null
|
|
|
|
COUNT=`apt list --upgradable 2> /dev/null | wc -l`
|
|
|
|
let COUNT--
|
|
|
|
echo $COUNT > /home/jpm/.spool/apt-upgradeable
|
|
|
|
else
|
|
|
|
echo "Missing argument: update, upgrade"
|
|
|
|
fi
|