From ef128a0d2fb57d752fc71febf6573ba965b077e5 Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Mon, 11 Apr 2022 14:39:18 +0100 Subject: Add list of upgradeable source packages to notification --- adu-download | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/adu-download b/adu-download index 57a4716..b58ab97 100755 --- a/adu-download +++ b/adu-download @@ -59,8 +59,26 @@ apt-get -q -y --with-new-pkgs --download-only upgrade | grep "^Get:" | cat ln -s -- "${UPDATE_TARGET}" "${UPDATE_SYMLINK}" 2>/dev/null || true +# Take a list on standard input, and output them all together separated by $1 +listify() { + sep="" + while read -r line; do + printf "%s" "${sep}${line}" + sep="$1" + done + printf "\\n" +} + # Notify logged-in users that updates are available if command -v notify-send >/dev/null; then + sources="$(echo "$upgradeable" \ + | cut -d / -f 1 \ + | xargs -n 1 apt-cache showsrc 2>/dev/null \ + | grep ^Package: \ + | cut -d " " -f 2 \ + | sort -u \ + | listify ", ")" + # Disable shellcheck's "For loops over find output are fragile" warning here # because filenames in `/run/user` are safe, and doing it The Right Way is a # pain because of the environment variable. @@ -70,7 +88,7 @@ if command -v notify-send >/dev/null; then runuser -u "$(stat -c "%U" "$addr")" -- \ notify-send --app-name=apt-desktop-upgrades \ "$upgrades system updates available" \ - "To install them, reboot when it is convenient" + "To install them, reboot when it is convenient\\nUpdates from $sources" done fi -- cgit v1.2.1