Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ Feel free to open a pull request to add new themes! :^)
> + "on-click": "ghostty -e ..."
> ```

<details>
<summary>System Update</summary>

The system update module requires `notify-send` (libnotify) and optionally an
AUR helper for checking AUR packages.

| Helper | Check Official | Check AUR | Update Both |
| :------------ | :------------: | :-------: | :--------: |
| **aura** | ✓ | ✓ | ✓ |
| **paru** | ✓ | ✓ | ✓ |
| **pikaur** | ✓ | ✓ | ✓ |
| **trizen** | ✓ | ✓ | ✓ |
| **yay** | ✓ | ✓ | ✓ |

If an AUR helper is installed, it will be used for all update checking and
upgrading (official repos and AUR).

If **no AUR helper** is installed:
- Only official Arch repositories can be checked/updated
- `checkupdates` (from `pacman-contrib`) is required
- AUR packages will not be checked or updated

</details>

#

### Installation
Expand Down
80 changes: 55 additions & 25 deletions scripts/system-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
# Waybar
#
# Requirements:
# - checkupdates (pacman-contrib)
# - notify-send (libnotify)
# - Optional: An AUR helper
# - checkupdates (pacman-contrib) — only needed if no AUR helper is installed
# - AUR helper (optional) — aura, paru, pikaur, trizen, or yay
#
# Author: Jesse Mirabel <sejjymvm@gmail.com>
# Date: August 16, 2025
# License: MIT

set -o pipefail

FG_GREEN="\e[32m"
FG_BLUE="\e[34m"
FG_RESET="\e[39m"

FAILURE=false
PAC_UPD=0
AUR_UPD=0
HELPER=

TIMEOUT=10
HELPERS=(aura paru pikaur trizen yay)
Expand All @@ -38,43 +41,70 @@ get_helper() {
done
}

check_updates() {
local pac_output pac_status
reset_state() {
FAILURE=false
PAC_UPD=0
AUR_UPD=0
}

pac_output=$(timeout $TIMEOUT checkupdates)
pac_status=$?
get_ignored_pkgs() {
grep -E "^IgnorePkg" /etc/pacman.conf | sed 's/IgnorePkg = //' | tr ' ' '\n' | grep -v '^$'
}

if ((pac_status != 0 && pac_status != 2)); then
FAILURE=true
return 1
filter_ignored() {
local ignored
ignored=$(get_ignored_pkgs)
if [[ -z $ignored ]]; then
cat
else
grep -v -F -f <(echo "$ignored") || true
fi
}

PAC_UPD=$(grep -c . <<< "$pac_output")
check_updates() {
reset_state

if [[ -z $HELPER ]]; then
return 0
fi
if [[ -n $HELPER ]]; then
local pac_output pac_status
pac_output=$(timeout $TIMEOUT "$HELPER" -Qud | filter_ignored)
pac_status=$?

local aur_output aur_status
if ((pac_status != 0 && pac_status != 2)); then
FAILURE=true
return 1
fi
PAC_UPD=$(grep -c . <<< "$pac_output")

aur_output=$(timeout $TIMEOUT "$HELPER" -Quaq)
aur_status=$?
local aur_output aur_status
aur_output=$(timeout $TIMEOUT "$HELPER" -Qua | filter_ignored)
aur_status=$?

if ((${#aur_output} > 0 && aur_status != 0)); then
FAILURE=true
return 1
fi
if ((${#aur_output} > 0 && aur_status != 0)); then
FAILURE=true
return 1
fi
AUR_UPD=$(grep -c . <<< "$aur_output")
else
local pac_output pac_status
pac_output=$(timeout $TIMEOUT checkupdates | filter_ignored)
pac_status=$?

AUR_UPD=$(grep -c . <<< "$aur_output")
if ((pac_status != 0 && pac_status != 2)); then
FAILURE=true
return 1
fi
PAC_UPD=$(grep -c . <<< "$pac_output")
AUR_UPD=0
fi
}

update_packages() {
printf "%bUpdating pacman packages...%b\n" "$FG_BLUE" "$FG_RESET"
sudo pacman -Syu

if [[ -n $HELPER ]]; then
printf "\n%bUpdating AUR packages...%b\n" "$FG_BLUE" "$FG_RESET"
printf "%bUpdating packages ($HELPER)...%b\n" "$FG_BLUE" "$FG_RESET"
command "$HELPER" -Syu
else
printf "%bUpdating packages (pacman)...%b\n" "$FG_BLUE" "$FG_RESET"
sudo pacman -Syu
fi

notify-send "Update Complete" -i "package-install"
Expand Down