Created
April 2, 2024 11:22
-
-
Save shaked8634/fd23ea4c8ec611faa206e87a460d6233 to your computer and use it in GitHub Desktop.
Pacman script to notify if kernel requires restart is required after upgrade (replace '_' with '/' in filenames)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trigger] | |
Operation = Install | |
Operation = Upgrade | |
Operation = Remove | |
Type = Package | |
Target = * | |
[Action] | |
Description = Checking if kernel requires restart | |
When = PostTransaction | |
Exec = /usr/local/bin/check_running_kernel.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
LINUX=$(uname -r) | |
if [[ "$LINUX" == *-lts ]]; then | |
installed_ver=$(pacman -Q linux-lts | awk '{print $NF}')-lts | |
else | |
installed_ver=$(pacman -Q linux | awk '{print $NF}' | rev | sed 's/\./-/' | rev) | |
fi | |
if [[ $installed_ver != "$LINUX" ]]; then | |
socket=$(ls /tmp/.X11-unix/* | head -n 1) | |
display=":$(ls $socket | sed 's#/tmp/.X11-unix/X##' | head -n 1)" | |
user=$(stat -c %U /tmp/.X11-unix/X0) | |
uid=$(id -u $user) | |
command="DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send \"$LINUX kernel was upgrade\". \"System requires restart\"" | |
doas -u $user sh -c "$command" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment