Re: apt update vs. KDE Discover?
Just a few notes:
On Fri, Apr 25, 2025 at 10:39:58 -0400, Lee wrote:
> #!/bin/bash
> # see if there are any Debian updates and pop-up a notice if there are
>
> # needs an /etc/sudoers.d/adm-apt-privs that has
> # Cmnd_Alias ADM_COMMANDS = /usr/bin/apt update
> # %adm ALL = (root) NOPASSWD: ADM_COMMANDS
>
> # get a temporary file
> tempf=$(mktemp -q --tmpdir=/tmp -t updXXXXX)
> stat=$?
> if [ ${stat} != 0 ]; then
> echo "OhNoes!!! Unable to create a temporary file. Status: ${stat}"
> exit 9
> fi
You're not actually using the exit code, other than to check for
success vs. failure, so you could do this instead:
if ! tempf=$(mktemp -q --tmpdir=/tmp -t updXXXXX); then
echo "OhNoes!!! ..." >&2
exit 9
fi
> size=$(ls -s $tempf | awk '{print $1}')
>
> [ $size != "0" ] && \
> notify-send -u critical "Debian updates available" "$(cat $tempf)"
Again, you're not actually using the size, other than to check whether
the file is empty. The shell has a builtin test operator for empty
vs. non-empty files: -s.
Also, you should quote "$tempf".
[ -s "$tempf" ] && notify-send ...
Reply to: