Skip to content

Commit c57208b

Browse files
committed
store DISPLAY and XAUTHORITY in ~/.Xenv #8
1 parent 0d6debd commit c57208b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ In future runs of the terminal you can directly run Linux GUI applications, e.g.
111111
pcmanfm
112112
```
113113
114+
### Use an already running X server
115+
- If you specify option `--display`, runx will check if an X server is already running
116+
with the specified display number and will only provide the access credentials
117+
`DISPLAY` and `XAUTHORITY` instead of running an additional X server.
118+
- The access credentials are also stored in file `~/.Xenv`.
119+
You can make them available in a new terminal sourcing the file with `. ~/.Xenv` or `source ~/.Xenv`.
120+
114121
## Output of `runx --help`
115122
```
116123
runx - Run Linux GUI applications on MS Windows.
@@ -129,7 +136,8 @@ Options:
129136
--xwin Use X server XWin.
130137
--clipboard [=yes|no] Enable clipboard sharing yes/no. Default: yes.
131138
--display N Use display number N for new X server.
132-
Default: random number in range of 100...3376.
139+
If the display number is already in use, runx will
140+
only provide the likely access credentials.
133141
--ip ADRESS IP adress to use. Default: First found 192.168.*
134142
--no-auth Disable X cookie authentication. Discouraged.
135143
--cleanup Stop all X servers and delete cookies.
@@ -171,8 +179,15 @@ Providing an X server in background all the time:
171179
- Create an entry in ~/.bashrc: source /usr/local/bin/runx
172180
- In future terminal session you can directly run GUI commands.
173181
E.g. just type: 'pcmanfm' instead of 'runx -- pcmanfm'.
182+
- If you specify a display number with --display, runx will re-use
183+
a possibly already running X server with same display number
184+
and only provide the access credentials DISPLAY and XAUTHORITY.
185+
This allows to use the same X server across several terminals.
186+
187+
runx stores the access credentials DISPLAY and XAUTHORITY in ~/.Xenv
188+
This allows sourcing the file for custom access setups.
174189

175-
runx version v0.4.3
190+
runx version 0.4.20
176191
Please report issues and get help at: https://github.com/mviereck/runx
177192
```
178193

runx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /bin/bash
22
# runx: Provide an X server in Cygwin, MSYS2 or WSL.
33

4-
Version="v0.4.18"
4+
Version="v0.4.20"
55

66
usage() { # Usage information (--help)
77
echo "runx - Run Linux GUI applications on MS Windows.
@@ -63,6 +63,13 @@ Providing an X server in background all the time:
6363
- Create an entry in ~/.bashrc: source /usr/local/bin/runx
6464
- In future terminal session you can directly run GUI commands.
6565
E.g. just type: 'pcmanfm' instead of 'runx -- pcmanfm'.
66+
- If you specify a display number with --display, runx will re-use
67+
a possibly already running X server with same display number
68+
and only provide the access credentials DISPLAY and XAUTHORITY.
69+
This allows to use the same X server across several terminals.
70+
71+
runx stores the access credentials DISPLAY and XAUTHORITY in ~/.Xenv
72+
This allows sourcing the file for custom access setups.
6673
6774
runx version $Version
6875
Please report issues and get help at: https://github.com/mviereck/runx
@@ -283,7 +290,6 @@ check_displayport() { # Return 0 if display number $1 is in use
283290
(</dev/tcp/"$Hostip"/$((6000+${1:-})) ) >/dev/null 2>&1
284291
}
285292
check_host() { # Check host environment
286-
287293
# Check for MS Windows subsystem
288294
command -v cygcheck.exe >/dev/null && {
289295
cygcheck.exe -V | rmcr | grep -q "(cygwin)" && Winsubsystem="CYGWIN"
@@ -606,6 +612,7 @@ declare_variables() {
606612
Sharegpu="no"
607613
Verbose="no"
608614
Xauthentication="yes"
615+
Xenvfile="$HOME/.Xenv"
609616

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

0 commit comments

Comments
 (0)