Created
September 24, 2023 11:40
-
-
Save CodyKochmann/f7b9baf1a3c3b40c01782da00ccfef3c to your computer and use it in GitHub Desktop.
how to run an interactive gui program from another user on debian 12
This file contains hidden or 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 | |
# by: Cody Kochmann | |
# how to run an interactive gui program from another user on debian 12 | |
# inspired by https://gist.github.com/kasunbg/5502cb630429819d07b5dc0cfa26813c | |
export NEW_USER_NAME=cody-facebook | |
#--------------------------------- | |
# step 1 - create a new user | |
#--------------------------------- | |
# switch to root | |
su | |
# create the new user | |
useradd -d "/home/${NEW_USER_NAME}" -m "$NEW_USER_NAME" | |
# set the users unique password | |
passwd "$NEW_USER_NAME" | |
# add the new user to the access control list for displays | |
xhost "+SI:localuser:${NEW_USER_NAME}" | |
# add the user to the sound group so they gui apps can use sound | |
usermod -G audio -a "${NEW_USER_NAME}" | |
# exit root user session | |
exit | |
#--------------------------------- | |
# step 2 - record the display id | |
#--------------------------------- | |
# record the value for $DISPLAY | |
echo $DISPLAY | tee /tmp/display.id | |
#-------------------------------------------------------- | |
# step 3 - now the new user can launch gui applications | |
#-------------------------------------------------------- | |
# switch to new user | |
su - "$NEW_USER_NAME" | |
# load the display value | |
export DISPLAY=$(cat /tmp/display.id | grep .) | |
# now the $NEW_USER_NAME can startup gui programs while the og user is still signed in | |
firefox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment