#!/bin/sh # Run only if user logged in (prevent cron errors) w | grep "^$USER\W" >/dev/null || exit # Don't try to sync if pacman is already running if pidof pacman; then exit fi napp="System upgrade" ni="preferences-system-linux" # Check several times before giving up, useful when just waking up from sleep # since internet is usually not available right away wget -q --tries=5 --timeout=20 --spider 1.1.1.1 > /dev/null || exit # Source the needed env variables so that it can function properly from cron . ~/.cache/sessionenv notify-send -a "$napp" -i "$ni" -e "Syncing repositories and downloading packages..." touch ~/.cache/pacsynclive killall -41 waybar if ! sudo pacman -Syuw --noconfirm; then notify-send -a "$napp" -i "$ni" -u critical -t 3000 "Error downloading updates. fi rm -f ~/.cache/pacsynclive killall -41 waybar upno=$(pacman -Qu | wc -l) if [ $upno -gt 0 ]; then notify-send -a "$napp" -i "$ni" "Repository sync finished. $upno updates are available" fi