improve update notification
This commit is contained in:
parent
5f1819a193
commit
ad069d90eb
4 changed files with 31 additions and 19 deletions
|
@ -42,3 +42,6 @@
|
||||||
highlight = "#ff768e"
|
highlight = "#ff768e"
|
||||||
timeout = 10
|
timeout = 10
|
||||||
|
|
||||||
|
[updates]
|
||||||
|
category = updates
|
||||||
|
timeout = 0
|
||||||
|
|
|
@ -4,30 +4,32 @@
|
||||||
|
|
||||||
notify-send " Repository Sync" "Checking for package updates..."
|
notify-send " Repository Sync" "Checking for package updates..."
|
||||||
|
|
||||||
if command -v pacman; then
|
askupgrade() {
|
||||||
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."
|
[ "$(notify-send -c updates --action=Yes=Yes --action=No=No " Repository Sync" "Updates available. Update now?")" = 'Yes' ] && $TERMINAL -e upgrades
|
||||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
}
|
||||||
|
|
||||||
if pacman -Qu | grep -v "\[ignored\]"; then
|
confirmcheck() {
|
||||||
answer=$(
|
|
||||||
notify-send --action=Yes=Yes --action=No=No \
|
|
||||||
" Repository Sync" "Updates available. Update now?"
|
|
||||||
)
|
|
||||||
[ $answer -eq 1 ] && $TERMINAL -e upgrades
|
|
||||||
else
|
|
||||||
notify-send " Repository Sync" "Sync complete. No new packages for update."
|
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
|
||||||
|
askupgrade
|
||||||
|
else
|
||||||
|
confirmcheck
|
||||||
fi
|
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)
|
n=$(sudo apt upgrade -dy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9' | cut -c1-2)
|
||||||
if [ "$n" = '' ]; then
|
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
|
elif [ "$n" = 00 ]; then
|
||||||
notify-send " Repository Sync" "Sync complete. No new packages for update."
|
confirmcheck
|
||||||
else
|
else
|
||||||
notify-send --action=Yes=Yes --action=No=No \
|
askupgrade
|
||||||
" Repository Sync" "Updates available. Update now?"
|
|
||||||
[ "$answer" = 1 ] && $TERMINAL -e upgrades
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,7 +4,7 @@ if command -v pacman 1>/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v apt 1>/dev/null 2>&1; then
|
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
|
for i in $vals; do
|
||||||
[ $i != 0 ] && icon="\033[11m\033[10m"
|
[ $i != 0 ] && icon="\033[11m\033[10m"
|
||||||
|
|
|
@ -11,6 +11,13 @@ fi
|
||||||
|
|
||||||
command -v apt 1>/dev/null 2>&1 && sudo apt upgrade
|
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"
|
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
|
||||||
read -r _
|
read -r _
|
||||||
|
exit
|
||||||
|
|
Loading…
Add table
Reference in a new issue