kernel-manager/usr/bin/archlinux-kernel-manager
arcolinuxz a62abdff41 update
2024-05-20 09:28:14 +02:00

52 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env sh
# this script should not be run as root
# the polkit agent running on the desktop environment should prompt for root password
echo "---------------------------------------------------------------------------"
echo "[INFO] Checking session"
test $(whoami) == "root" && echo "[ERROR] Do not run this script as root." && exit 1
test -z $DISPLAY && echo "[ERROR] DISPLAY variable is not set." && exit 1
# check session is either one of X11, Wayland or TTY
session=$(loginctl show-session $(loginctl|grep $(whoami) | awk '{print $1}') -p Type | awk -F= '{print $2}' | grep "x11\|wayland\|tty")
test -z "$session" && echo "[ERROR] Failed to verify session for user." && exit 1
xauth_file=$(xauth info | awk -F"Authority file:" '{print $2}' | tr -d ' ')
test -s "$xauth_file" || touch "$xauth_file"
case "$session" in
"wayland")
# Wayland session, generate Xauth session cookie for $DISPLAY
xauth gen $DISPLAY &> /dev/null
echo "[INFO] Display = $DISPLAY"
echo "[INFO] Session = $session"
test -z "$(xauth list)" || echo "[INFO] Xauth session = OK"
;;
"x11")
# X11 session, don't do anything here
echo "[INFO] Display = $DISPLAY"
echo "[INFO] Session = $session"
# just show msg on whether the Xauth session cookie is setup
test -z "$(xauth list)" || echo "[INFO] Xauth session = OK"
;;
"tty")
# TTY session, as user may not use a display manager
echo "[INFO] Display = $DISPLAY"
echo "[INFO] Session = $session"
test -z "$(xauth list)" || echo "[INFO] Xauth session = OK"
;;
*)
# anything here is an unknown session, most likely AKM will fail to load
echo "[WARN] Continuing, but cannot verify session for user."
;;
esac
echo "---------------------------------------------------------------------------"
echo "[INFO] Starting Arch Linux Kernel Manager"
pkexec '/usr/share/archlinux-kernel-manager/archlinux-kernel-manager.py'