update script
This commit is contained in:
parent
c3cb2d6853
commit
30bea1fc71
1 changed files with 59 additions and 0 deletions
59
home/private_bin/executable_get-updates
Normal file
59
home/private_bin/executable_get-updates
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
cat <<HELP
|
||||
|
||||
get-updates [option]
|
||||
|
||||
--notify send a notification with available packages
|
||||
-h,--help print this page and exit
|
||||
|
||||
HELP
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
updates_output() {
|
||||
notify=$1
|
||||
if ! [[ -z $updates_arch ]]; then
|
||||
echo "ARCH: $(echo "$updates_arch" | wc -l )"
|
||||
[[ -z $notify ]] && echo "$updates_arch"
|
||||
fi
|
||||
if ! [[ -z $updates_aur ]]; then
|
||||
echo "AUR:"
|
||||
[[ -z $notify ]] && echo "$updates_aur"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
for opt in "$@"; do
|
||||
case $opt in
|
||||
-h | --help)
|
||||
usage
|
||||
;;
|
||||
--notify)
|
||||
notify=1
|
||||
shift
|
||||
;;
|
||||
-* | --*)
|
||||
echo "Invalid option: $opt"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
updates_arch="$(checkupdates 2> /dev/null | awk '{print $1}')"
|
||||
updates_aur="$(pikaur -Qua 2> /dev/null | awk '{print $1}')"
|
||||
updates_info="$(updates_output $notify)"
|
||||
|
||||
if [[ -z $updates_info ]];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [[ -z $notify ]]; then
|
||||
notify-send -t 60000 "System Updates Available!" "$updates_info"
|
||||
else
|
||||
echo "System Updates Available!"
|
||||
echo "$updates_info"
|
||||
fi
|
Loading…
Reference in a new issue