mirror of
https://github.com/Snigdha-OS/snigdhaos-pkgbuilds.git
synced 2025-09-22 12:35:01 +02:00
🛠️ build(_logic): updated with efficient logic
This commit is contained in:
@@ -1,15 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Determine whether to use GUI authentication based on environment and variable
|
||||||
SNIGDHAOSLIB_GUI="${SNIGDHAOSLIB_GUI:-true}"
|
SNIGDHAOSLIB_GUI="${SNIGDHAOSLIB_GUI:-true}"
|
||||||
|
|
||||||
|
# If running in a non-graphical environment, disable GUI authentication
|
||||||
if [ -z "$DISPLAY" ]; then
|
if [ -z "$DISPLAY" ]; then
|
||||||
SNIGDHAOSLIB_GUI=false
|
SNIGDHAOSLIB_GUI=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if we need to run with elevated privileges and handle accordingly
|
||||||
if [[ $EUID -ne 0 ]] && [ "$SNIGDHAOSLIB_GUI" == "true" ]; then
|
if [[ $EUID -ne 0 ]] && [ "$SNIGDHAOSLIB_GUI" == "true" ]; then
|
||||||
|
# Use pkexec to elevate with GUI if necessary
|
||||||
exec pkexec /usr/lib/snigdhaos/install-package "$@"
|
exec pkexec /usr/lib/snigdhaos/install-package "$@"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
||||||
|
Reference in New Issue
Block a user