From b0afcca59f130ef981a3ddb29900dcd2de4fbe18 Mon Sep 17 00:00:00 2001 From: "Eshan Roy (Eshanized)" Date: Sun, 28 Apr 2024 22:27:30 +0530 Subject: [PATCH] =?UTF-8?q?=E2=8F=B3=20@eshanized=20updated=20the=20reposi?= =?UTF-8?q?tory!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/bin/blackbox | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 usr/bin/blackbox diff --git a/usr/bin/blackbox b/usr/bin/blackbox new file mode 100644 index 0000000..2742918 --- /dev/null +++ b/usr/bin/blackbox @@ -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' \ No newline at end of file