diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc index 33bd6da7..d2fb5bfe 100644 --- a/.config/dunst/dunstrc +++ b/.config/dunst/dunstrc @@ -42,3 +42,6 @@ highlight = "#ff768e" timeout = 10 +[updates] + category = updates + timeout = 0 diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup index 02f3773d..78fbbce2 100755 --- a/.local/bin/cron/checkup +++ b/.local/bin/cron/checkup @@ -4,30 +4,32 @@ notify-send " Repository Sync" "Checking for package updates..." -if command -v pacman; then - sudo pacman -Syyuw --noconfirm || notify-send "Error downloading updates." "Check your internet connection, if pacman is already running, or run update manually to see errors." - pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" +askupgrade() { + [ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMINAL -e upgrades +} +confirmcheck() { + notify-send " Repository Sync" "Sync complete. No new packages for update." +} + +failcheck() { + notify-send "Error downloading updates." "Check your internet connection, if $1 is already running, or run update manually to see errors." +} + +if command -v pacman 1>/dev/null 2>&1; then + sudo pacman -Syyuw --noconfirm || failcheck pacman if pacman -Qu | grep -v "\[ignored\]"; then - answer=$( - notify-send --action=Yes=Yes --action=No=No \ - " Repository Sync" "Updates available. Update now?" - ) - [ $answer -eq 1 ] && $TERMINAL -e upgrades + askupgrade else - notify-send " Repository Sync" "Sync complete. No new packages for update." + confirmcheck fi -elif command -v apt; then +elif command -v apt 1>/dev/null 2>&1; then n=$(sudo apt upgrade -dy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9' | cut -c1-2) if [ "$n" = '' ]; then - notify-send "Error downloading updates." "Check your internet connection, if pacman is already running, or run update manually to see errors." + failcheck apt elif [ "$n" = 00 ]; then - notify-send " Repository Sync" "Sync complete. No new packages for update." + confirmcheck else - notify-send --action=Yes=Yes --action=No=No \ - " Repository Sync" "Updates available. Update now?" - [ "$answer" = 1 ] && $TERMINAL -e upgrades + askupgrade fi - - pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" fi diff --git a/.local/bin/statusbar/sb-packages b/.local/bin/statusbar/sb-packages index 068931b7..31d8862e 100755 --- a/.local/bin/statusbar/sb-packages +++ b/.local/bin/statusbar/sb-packages @@ -4,7 +4,7 @@ if command -v pacman 1>/dev/null 2>&1; then fi if command -v apt 1>/dev/null 2>&1; then - vals=$(apt upgrade -sy | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9 ' | tr ' ' '\n' | grep '[0-9]\+' | xargs echo) + vals=$(apt upgrade -sy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9 ' | tr ' ' '\n' | grep '[0-9]\+' | xargs echo) for i in $vals; do [ $i != 0 ] && icon="\033[11m\033[10m" diff --git a/.local/bin/upgrades b/.local/bin/upgrades index e41d6544..d1eb9c2b 100755 --- a/.local/bin/upgrades +++ b/.local/bin/upgrades @@ -11,6 +11,13 @@ fi command -v apt 1>/dev/null 2>&1 && sudo apt upgrade -pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" +# This pkill is already handled by apt/pacman hooks: +# pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" +# +# create the file /etc/apt/apt.conf.d/80statusbar containing the following +# DPkg::Post-Invoke {"/usr/bin/pkill -RTMIN+8 dwmblocks";}; +# TODO: provide example for pacman hook + printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" read -r _ +exit