@eshanized updated the repository!!!

This commit is contained in:
Eshan Roy (Eshanized)
2024-04-28 22:27:30 +05:30
parent 406e40c6a3
commit b0afcca59f

48
usr/bin/blackbox Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env sh
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 Sofirem will fail to load
echo "[WARN] Cannot verify session for user."
;;
esac
echo "---------------------------------------------------------------------------"
echo "[INFO] Starting BlackBox"
pkexec '/usr/share/blackbox/blackbox.py'