From 3cfd64791f8f7e470549b1ca197ab4ab4430656d Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Wed, 27 Nov 2024 20:22:49 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(=5Frefined):=20ensure?= =?UTF-8?q?=20pkexec=20is=20isntalled!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snigdhaos-libs/pkexec-gui | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/snigdhaos-libs/pkexec-gui b/snigdhaos-libs/pkexec-gui index 23fbb0ab..8f4b9149 100755 --- a/snigdhaos-libs/pkexec-gui +++ b/snigdhaos-libs/pkexec-gui @@ -1,5 +1,12 @@ #!/bin/bash +# Ensure pkexec is available +if ! command -v pkexec &>/dev/null; then + echo "Error: pkexec is not installed. Please install PolicyKit." + exit 1 +fi + +# Check if running as root if [ $EUID -ne 0 ]; then exec pkexec /usr/lib/snigdhaos/pkexec-gui "$@" exit 1 @@ -8,8 +15,14 @@ fi # Need some previous vars # shellcheck disable=SC2163 while IFS= read -rd '' var; do export "$var"; done < <(grep --null-data -ae "^\($XDG_CURRENT_DESKTOP\|WAYLAND_DISPLAY\|XDG_RUNTIME_DIR\|XDG_SESSION_TYPE\|XCURSOR_SIZE\|LC_*\|LANG\|LANGUAGE\|QT_WAYLAND_FORCE_DPI\|QT_QPA_PLATFORMTHEME\|QT_STYLE-OVERRIDE\|\)=.*\$" /proc/$PPID/environ) + +# If on Wayland, adjust WAYLAND_DISPLAY variable if [[ -v WAYLAND_DISPLAY ]]; then export WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" fi + +# Set root's runtime directory export XDG_RUNTIME_DIR="/run/user/0" + +# Execute the provided command with root privileges exec "$@"