omarchy/bin/omarchy-update-restart
Eric Swanson ac207720f8
Fix kernel update detection for alternative kernel variants (#585)
* Fix omarchy-update kernel update message to support alternative kernel variants

* fix: omarchy-update-restart kernel update message to support alternative kernel variants
2025-08-12 08:27:00 +02:00

25 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Check for kernel package updates since last boot
boot_time=$(date -d "$(uptime -s)" '+%Y-%m-%d %H:%M')
recent_kernel_updates=$(awk -v boot_time="$boot_time" '$0 >="["boot_time' /var/log/pacman.log | grep -E "\[ALPM\] (upgraded|installed) (linux|linux-zen|linux-lts|linux-hardened)\b" || true)
if [ -n "$recent_kernel_updates" ]; then
gum confirm "Linux kernel has been updated. Reboot?" && omarchy-state clear re*-required && sudo reboot now
elif [ -f "$HOME/.local/state/omarchy/reboot-required" ]; then
gum confirm "Updates require reboot. Ready?" && omarchy-state clear re*-required && sudo reboot now
elif [ -f "$HOME/.local/state/omarchy/relaunch-required" ]; then
gum confirm "Updates require Hyprland relaunch. Ready?" && omarchy-state clear re*-required && uwsm stop
fi
for file in "$HOME"/.local/state/omarchy/restart-*-required; do
if [ -f "$file" ]; then
filename=$(basename "$file")
service=$(echo "$filename" | sed 's/restart-\(.*\)-required/\1/')
echo "Restarting $service"
omarchy-state clear "$filename"
omarchy-restart-"$service"
fi
done