Skip to content

Commit

Permalink
--xwin: Use random display number #165
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Jun 19, 2019
1 parent a3905f3 commit c8ced7a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
16 changes: 9 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ Project website: https://github.com/mviereck/x11docker
- `--vcxsrv`: X server on Windows. Use `runx` on MS Windows instead
to provide X for x11docker: https://github.com/mviereck/runx
- `--pulseaudio` on MS Windows is no longer supported.
- `--ps`, `--trusted`, `--untrusted`, `--no-xtest`, `--no-xhost`, `--silent`,
`--stderr`, `--stdout`, `--nothing`, `--cachedir`, `--sharedir`,`--starter`,
- `--ps`, `--trusted`, `--untrusted`, `--no-xtest`, `--no-xhost`,
`--silent`, `--stderr`, `--stdout`, `--nothing`, `--cachedir`, `--starter`,
`--tini`, `--systemd`, `--openrc`, `--runit`, `--sysvinit`, `--no-init`,
`--sys-admin`: Removed; search this changelog for possible replacements in
`--sys-admin`: Removed; search this changelog for possible replacements
noted in 'Deprecated' chapters.

### Fixed
- `--gpu` with automated NVIDIA driver installation:
Don't set `--security-opt=no-new-privileges`.
[(#162)](https://github.com/mviereck/x11docker/issues/162)
- `--hostwayland`: Fix socket name issue.
[(ehough/kodi #26)](https://github.com/ehough/docker-kodi/issues/26)
- WSL: Add Windows System32 path to `PATH`. Can miss with `sudo`.
[(#153)](https://github.com/mviereck/x11docker/issues/153)
- `--update`, `--update-master`: Support more common `tar` beside `unzip`.
[(#115)](https://github.com/mviereck/x11docker/issues/115)
- `--xwin`: fix for free display number check.
Add `xwininfo` to dependency check of `--xwin`.
[(#155)](https://github.com/mviereck/x11docker/issues/155)
- `--xwin`: Use random display number.
[(#165)](https://github.com/mviereck/x11docker/issues/165)
- `--xpra`: Check for option `--modal-windows`.
[(#167)](https://github.com/mviereck/x11docker/issues/167)


## [5.6.0](https://github.com/mviereck/x11docker/releases/tag/v5.6.0) - 2019-05-02
Expand Down
31 changes: 20 additions & 11 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -2199,14 +2199,21 @@ $(xhost 2>&1 )"
}
check_newxenv() { # find free display, create $Newxenv
# find free display number
[ "$Newdisplaynumber" ] || for ((Newdisplaynumber=100 ; Newdisplaynumber <=1000 ; Newdisplaynumber++)); do
[ -n "$(find /tmp/.X11-unix/X$Newdisplaynumber /tmp/.X$Newdisplaynumber-lock ${XDG_RUNTIME_DIR:-}/wayland-$Newdisplaynumber 2>/dev/null)" ] || {
case $Xserver in
--xwin) grep -q -E 'Authorization|Absolute|MIT-MAGIC-COOKIE' <<< "$(xwininfo -display $Hostip:$Newdisplaynumber -root 2>&1)" || break ;;
*) break ;;
esac
}
done
[ "$Newdisplaynumber" ] || {
case $Xserver in
--xwin)
Newdisplaynumber="$((RANDOM / 10))"
note "Using random X display number :$Newdisplaynumber.
If this display number is already in use, x11docker will fail.
You can specify a display number N with option '--display N'."
;;
*)
for ((Newdisplaynumber=100 ; Newdisplaynumber <=1000 ; Newdisplaynumber++)); do
[ -n "$(find /tmp/.X11-unix/X$Newdisplaynumber /tmp/.X$Newdisplaynumber-lock ${XDG_RUNTIME_DIR:-}/wayland-$Newdisplaynumber 2>/dev/null)" ] || break
done
;;
esac
}

# X over IP/TCP
[ "$Xoverip" ] || case $Xserver in
Expand Down Expand Up @@ -5250,7 +5257,7 @@ $(tail $Compositorlogfile)"
Xinitpid="$(pgrep -a xinit 2>/dev/null | grep "xinit $Xinitrc" | awk '{print $1}')"
checkpid "$Xinitpid" && setonwatchpidlist $Xinitpid xinit && storepid $Xinitpid xinit
echo $Xcommand | grep -q Xorgwrapper && Line="Xorg $Newdisplay" || Line="$(echo "$Xcommand" | head -n1)"
Xserverpid=$(ps aux | grep "$(echo "${Line:-nothingtolookfor}" | cut -d' ' -f1-2)" | grep -v grep | grep -v xinit | awk '{print $2}')
Xserverpid=$(ps aux | rmcr| grep "$(echo "${Line:-nothingtolookfor}" | cut -d' ' -f1-2)" | grep -v grep | grep -v xinit | awk '{print $2}')
checkpid "$Xserverpid" && setonwatchpidlist $Xserverpid Xserver && storepid $Xserverpid Xserver
;;
esac
Expand Down Expand Up @@ -7101,6 +7108,10 @@ ${2:-}" ; shift ;; # add custom root command in container
--cachebasedir) Cachebasefolder="${2:-}" ; shift ;; # set cache folder instead of default $Cachebasefolder
--share) store_runoption volume "${2:-}" # share host directory
shift ;;
--sharedir) store_runoption volume "${2:-}" # share host directory
note "Option --sharedir is deprecated.
Please use option --share=PATH instead."
shift ;;

## docker options
--hostipc) Sharehostipc="yes" ;; # docker run option --ipc=host
Expand All @@ -7123,8 +7134,6 @@ ${2:-}" ; shift ;; # add custom root command in container
Please use either option --xwin in Cygwin/X
or run x11docker with runx in WSL or MSYS2.
For 'runx' look at: https://github.com/mviereck/runx" ;;
--sharedir) error "Option ${1:-} has been removed.
Please use option --share=PATH instead." ;;
--no-init|--openrc|--runit|--systemd|--sysvinit|--tini)
error "Option ${1:-} has been removed.
Please use option --init=INITSYSTEM instead." ;;
Expand Down

0 comments on commit c8ced7a

Please sign in to comment.