#!/bin/bash

if [ $EUID -ne 0 ]; then
    exec pkexec /usr/lib/snigdhaos/pkexec-gui "$@"
    exit 1
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 [[ -v WAYLAND_DISPLAY ]]; then
    export WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"
fi
export XDG_RUNTIME_DIR="/run/user/0"
exec "$@"
