Skip to content

Instantly share code, notes, and snippets.

@cirrusUK
Created February 23, 2020 15:15
Show Gist options
  • Save cirrusUK/eb737d8b31455ad4b25f510c0d2ef268 to your computer and use it in GitHub Desktop.
Save cirrusUK/eb737d8b31455ad4b25f510c0d2ef268 to your computer and use it in GitHub Desktop.
#!/bin/bash
export XDG_RUNTIME_DIR=/run/user/$(id -u)
icon="/home/cirrus/.icons/48arch.png"
/usr/bin/ping -c 1 www.archlinux.org > /dev/null || { echo "archlinux.org is down. Aborting" && exit; }
ignore_db="AUR.db"
newest_db=$(ls -t -I ${ignore_db} /var/lib/pacman/sync | /usr/bin/head -n1)
newest_db_date=$(/usr/bin/stat /var/lib/pacman/sync/${newest_db} | /usr/bin/grep Modify | /usr/bin/sed s/Modify:\ //)
newest_db_date_utc=$(/usr/bin/date -u -d "${newest_db_date}" +%s)
newest_news_date=$(/usr/bin/curl -s --head https://www.archlinux.org/feeds/news/ | grep ^last-modified | sed -e s/^last-modified:\ //)
newest_news_date_utc=$(/usr/bin/date -u -d "${newest_news_date}" +%s)
if [[ $newest_news_date_utc -lt $newest_db_date_utc ]]; then
echo "There is no new news on the Arch homepage. Performing -Syu." && /usr/bin/sudo /usr/bin/pacman -Syu | bat
else
echo "There is news on the Arch homepage. Please review it before updating." && /usr/bin/sudo /usr/bin/pacman -Sy | bat
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment