From 29f0312c6580d1adf428cb966d49f2237b155a98 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Wed, 27 Nov 2024 20:18:27 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20build(=5Flogic):=20upda?= =?UTF-8?q?ted=20with=20efficient=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snigdhaos-libs/install-package | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/snigdhaos-libs/install-package b/snigdhaos-libs/install-package index 1d582fcd..b8a18a02 100755 --- a/snigdhaos-libs/install-package +++ b/snigdhaos-libs/install-package @@ -1,15 +1,25 @@ #!/bin/bash set -e +# Determine whether to use GUI authentication based on environment and variable SNIGDHAOSLIB_GUI="${SNIGDHAOSLIB_GUI:-true}" +# If running in a non-graphical environment, disable GUI authentication if [ -z "$DISPLAY" ]; then SNIGDHAOSLIB_GUI=false fi +# Check if we need to run with elevated privileges and handle accordingly if [[ $EUID -ne 0 ]] && [ "$SNIGDHAOSLIB_GUI" == "true" ]; then + # Use pkexec to elevate with GUI if necessary exec pkexec /usr/lib/snigdhaos/install-package "$@" exit 1 fi -sudo pacman -S --noconfirm "$@" +# Use sudo for elevation if we are not using pkexec +if [[ $EUID -ne 0 ]]; then + sudo pacman -S --noconfirm "$@" +else + # If we're already root, simply run pacman + pacman -S --noconfirm "$@" +fi