Skip to content

Commit

Permalink
store DISPLAY and XAUTHORITY in ~/.Xenv #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Aug 18, 2022
1 parent 0d6debd commit c57208b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ In future runs of the terminal you can directly run Linux GUI applications, e.g.
pcmanfm
```
### Use an already running X server
- If you specify option `--display`, runx will check if an X server is already running
with the specified display number and will only provide the access credentials
`DISPLAY` and `XAUTHORITY` instead of running an additional X server.
- The access credentials are also stored in file `~/.Xenv`.
You can make them available in a new terminal sourcing the file with `. ~/.Xenv` or `source ~/.Xenv`.
## Output of `runx --help`
```
runx - Run Linux GUI applications on MS Windows.
Expand All @@ -129,7 +136,8 @@ Options:
--xwin Use X server XWin.
--clipboard [=yes|no] Enable clipboard sharing yes/no. Default: yes.
--display N Use display number N for new X server.
Default: random number in range of 100...3376.
If the display number is already in use, runx will
only provide the likely access credentials.
--ip ADRESS IP adress to use. Default: First found 192.168.*
--no-auth Disable X cookie authentication. Discouraged.
--cleanup Stop all X servers and delete cookies.
Expand Down Expand Up @@ -171,8 +179,15 @@ Providing an X server in background all the time:
- Create an entry in ~/.bashrc: source /usr/local/bin/runx
- In future terminal session you can directly run GUI commands.
E.g. just type: 'pcmanfm' instead of 'runx -- pcmanfm'.
- If you specify a display number with --display, runx will re-use
a possibly already running X server with same display number
and only provide the access credentials DISPLAY and XAUTHORITY.
This allows to use the same X server across several terminals.

runx stores the access credentials DISPLAY and XAUTHORITY in ~/.Xenv
This allows sourcing the file for custom access setups.

runx version v0.4.3
runx version 0.4.20
Please report issues and get help at: https://github.com/mviereck/runx
```
Expand Down
14 changes: 12 additions & 2 deletions runx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /bin/bash
# runx: Provide an X server in Cygwin, MSYS2 or WSL.

Version="v0.4.18"
Version="v0.4.20"

usage() { # Usage information (--help)
echo "runx - Run Linux GUI applications on MS Windows.
Expand Down Expand Up @@ -63,6 +63,13 @@ Providing an X server in background all the time:
- Create an entry in ~/.bashrc: source /usr/local/bin/runx
- In future terminal session you can directly run GUI commands.
E.g. just type: 'pcmanfm' instead of 'runx -- pcmanfm'.
- If you specify a display number with --display, runx will re-use
a possibly already running X server with same display number
and only provide the access credentials DISPLAY and XAUTHORITY.
This allows to use the same X server across several terminals.
runx stores the access credentials DISPLAY and XAUTHORITY in ~/.Xenv
This allows sourcing the file for custom access setups.
runx version $Version
Please report issues and get help at: https://github.com/mviereck/runx
Expand Down Expand Up @@ -283,7 +290,6 @@ check_displayport() { # Return 0 if display number $1 is in use
(</dev/tcp/"$Hostip"/$((6000+${1:-})) ) >/dev/null 2>&1
}
check_host() { # Check host environment

# Check for MS Windows subsystem
command -v cygcheck.exe >/dev/null && {
cygcheck.exe -V | rmcr | grep -q "(cygwin)" && Winsubsystem="CYGWIN"
Expand Down Expand Up @@ -606,6 +612,7 @@ declare_variables() {
Sharegpu="no"
Verbose="no"
Xauthentication="yes"
Xenvfile="$HOME/.Xenv"

# Terminal colors used for messages and --verbose=c
Esc="$(printf '\033')"
Expand Down Expand Up @@ -740,6 +747,8 @@ main() {
or 'Invalid MIT-MAGIC-COOKIE', the X authentication cookie might be broken.
You can remove old cookies and stop running X servers with: runx --cleanup"
echo "DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
echo "export DISPLAY=$DISPLAY
export XAUTHORITY=$XAUTHORITY" > "$Xenvfile"
;;
no)
unset XAUTHORITY
Expand All @@ -750,6 +759,7 @@ main() {
Others could try to access your system through network connections.
Please use option --no-auth for debugging only."
echo "DISPLAY=$DISPLAY"
echo "export DISPLAY=$DISPLAY" > "$Xenvfile"
;;
esac
export DISPLAY XAUTHORITY
Expand Down

0 comments on commit c57208b

Please sign in to comment.