️ perf: extension wayland handling

This commit is contained in:
RiO
2024-12-24 02:52:07 +05:30
parent 19859b5611
commit 0062c26f03

View File

@@ -7,21 +7,25 @@ if ! command -v pkexec &>/dev/null; then
fi
# Check if running as root
if [ $EUID -ne 0 ]; then
if [[ $EUID -ne 0 ]]; then
# Attempt to execute the script as root via pkexec
exec pkexec /usr/lib/snigdhaos/pkexec-gui "$@"
exit 1
fi
# Need some previous vars
# Shellcheck disable: Read environment variables from parent process
# 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)
# Read the necessary environment variables from the parent process
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
# Adjust WAYLAND_DISPLAY if running on Wayland
if [[ -n "$WAYLAND_DISPLAY" ]]; then
export WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"
fi
# Set root's runtime directory
# Set the root user's XDG_RUNTIME_DIR
export XDG_RUNTIME_DIR="/run/user/0"
# Execute the provided command with root privileges