blob: e14bafb7a085e5c397d27d43c0004abb04739a13 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/bin/sh
# this script is based on some assumptions that are made in the context
# of my gentoo/swaywm setup
set -e
[ -n "$DEBUG" ] && set -x
usage() {
printf "usage: %s USER [ARGS...]" "$(basename "$0")\n"
printf "\n"
printf "enter the desktop session of USER and run COMMAND.\n"
exit 1
}
case "$1" in
-h) usage && exit 0 ;;
esac
user="${1}"
[ -z "${user}" ] && usage
shift
uid=$(id -u "${user}")
marker_bins="
oguri
kanshi
waybar
gammastep
pipewire
swayidle
"
pid=
for bin in ${marker_bins}; do
pid=$(cat "/run/user/"${uid}"/"${bin}".pid")
kill -0 "${pid}" && break
done
env=$(grep -zE '^(SWAY|I3|WAYLAND|DBUS|XDG|PATH)' /proc/"${pid}"/environ | tr '\0' ' ' || true)
exec doas -u "${user}" env ${env} "${@}"
|