Last active
August 16, 2024 05:18
-
-
Save unique-EJ/3e6142d8c1540f191866baf7b6c98b4d to your computer and use it in GitHub Desktop.
Start application, and X server, on a remote machine (SSH).
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
| # Start application, and X server, on a remote machine (SSH). | |
| # ". Xserver.sh [app name]", "pgrep [app name]" | |
| if [ $# -ge 1 ]; then | |
| app="$@" # The positional parameters (app). | |
| session="startlxde-pi" | |
| commands="\ | |
| cd /tmp/; mkfifo -m 607 .command; | |
| env echo -e \"declare DISPLAY=:0; \$(which ${session}) & | |
| ${app}\" > .command & | |
| env echo \"starting X server and app, ${app}\" | |
| xinit \$(which sudo) --user='$(logname)' --login source \$(env pwd -P)/.command\ | |
| -- :0 || exit 1; | |
| rm .command /tmp/.Xserver;" | |
| cd /tmp/ || exit 1; mkfifo -m 607 .Xserver # named pipe | |
| env echo -e "${commands}" > .Xserver & | |
| # Switch to new virtual terminal, start program. | |
| # shellcheck disable=SC2086 | |
| sudo openvt -l -s -- "$(which sudo)" --login -- source /tmp/.Xserver | |
| cd - | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get the SSH client IP address, do
"${SSH_CONNECTION%% *}"- remote control/connect to device?Switch to a Virtual Terminal in use (forced):
declare DISPLAY=:0; sudo openvt -f --console=1 -s -- $(which sudo) -u $(logname) -i env sleep 2declare DISPLAY=:0; sudo openvt -f --console=1 -s -- $(which sudo) -u $(logname) -i exit