update-notifier/pacman-update-count.sh

21 lines
494 B
Bash
Raw Normal View History

2020-02-17 13:59:52 +00:00
#!/bin/sh
_updates_available="0"
_target_file="/tmp/pacman-update-count"
_user="ray"
2020-02-17 14:20:13 +00:00
pacman -Sy
_query_output=$(pacman -Qu)
2020-02-17 13:59:52 +00:00
# TODO - get update count from above
echo "$_query_output"
# check $_updates_available is algebraically equal to itself (i.e., is a number)
# https://unix.stackexchange.com/a/151655
if ! [ "$_updates_available" -eq "$_updates_available" ] 2> /dev/null ; then
_updates_available="-1"
fi
echo "$_updates_available" > "$_target_file"
chown "$_user": "$_target_file"