update-notifier/pacman-update-count.sh

21 lines
494 B
Bash
Executable File

#!/bin/sh
_updates_available="0"
_target_file="/tmp/pacman-update-count"
_user="ray"
pacman -Sy
_query_output=$(pacman -Qu)
# 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"