summaryrefslogtreecommitdiff
path: root/polybar/scripts/polkit-agent.sh
diff options
context:
space:
mode:
Diffstat (limited to 'polybar/scripts/polkit-agent.sh')
-rwxr-xr-xpolybar/scripts/polkit-agent.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/polybar/scripts/polkit-agent.sh b/polybar/scripts/polkit-agent.sh
new file mode 100755
index 0000000..ed86a5f
--- /dev/null
+++ b/polybar/scripts/polkit-agent.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+export DISPLAY="${DISPLAY:-:0}"
+if [ -z "${XAUTHORITY:-}" ] && [ -r "$HOME/.Xauthority" ]; then
+ export XAUTHORITY="$HOME/.Xauthority"
+fi
+
+if pgrep -u "$UID" -f 'polkit-gnome-authentication-agent-1|polkit-kde-authentication-agent-1|lxqt-policykit-agent|polkit-mate-authentication-agent-1|xfce-polkit' >/dev/null 2>&1; then
+ exit 0
+fi
+
+agents=(
+ /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
+ /usr/lib/polkit-kde-authentication-agent-1
+ /usr/lib/lxqt-policykit/lxqt-policykit-agent
+ /usr/bin/lxqt-policykit-agent
+ /usr/lib/mate-polkit/polkit-mate-authentication-agent-1
+ /usr/lib/xfce-polkit/xfce-polkit
+)
+
+for agent in "${agents[@]}"; do
+ if [ -x "$agent" ]; then
+ exec "$agent"
+ fi
+done
+
+echo "No supported polkit authentication agent found" >&2
+exit 1