1
0
Fork 0

improve update notification

This commit is contained in:
Luca Bilke 2023-02-20 12:23:39 +01:00
parent 5f1819a193
commit ad069d90eb
4 changed files with 31 additions and 19 deletions

View File

@ -42,3 +42,6 @@
highlight = "#ff768e"
timeout = 10
[updates]
category = updates
timeout = 0

View File

@ -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

View File

@ -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"

View File

@ -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 <Enter> to exit window.\\n\\n"
read -r _
exit