summarylogtreecommitdiffstats
path: root/swaymsg-root.sh
diff options
context:
space:
mode:
Diffstat (limited to 'swaymsg-root.sh')
-rwxr-xr-xswaymsg-root.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/swaymsg-root.sh b/swaymsg-root.sh
new file mode 100755
index 000000000000..d1fff12cafec
--- /dev/null
+++ b/swaymsg-root.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+
+# it will get only the first instance of sway
+SWAY_PID="$(pgrep "^sway$" | head -n1)"
+USER_ID="$(stat -c "%u" "/proc/${SWAY_PID}/")"
+USER="$(id -nu "${USER_ID}")"
+
+SWAYSOCK="/run/user/${USER_ID}/sway-ipc.${USER_ID}.${SWAY_PID}.sock" su "${USER}" -c "swaymsg $*"