Last active
May 26, 2022 19:20
-
-
Save adam-currie/bdf1f8e94f3eceb7f87ec2accceb4df2 to your computer and use it in GitHub Desktop.
runs a command as another user with current users x server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
selfBaseName=$(basename -- "$(readlink -f -- "$0")") | |
usage="Usage: ${selfBaseName} <username> <command>" | |
if test $# -ne 2; then | |
echo $usage | |
exit | |
fi | |
user=$1 | |
cmd=$2 | |
xhost +SI:localuser:$user | |
pkexec --user $user env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $cmd | |
xhost -SI:localuser:$user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works with zsh, toss in /usr/local/bin or equivalent