Skip to content

Commit

Permalink
Default to IP 192.168.* #6
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Jan 17, 2021
1 parent 44cd221 commit 6532ee7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 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.3.0"
Version="v0.4"

usage() { # Usage information (--help)
echo "runx - Run Linux GUI applications on MS Windows.
Expand All @@ -21,6 +21,7 @@ Options:
--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.
--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.
-v, --verbose Be verbose.
Expand Down Expand Up @@ -323,10 +324,11 @@ check_host() { # Check host environment
Winsubmount="${Winsubmount%/}"
Winsubpath="${Winsubpath%/}"

# Check IP of Windows host
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep -A6 'DockerNAT' | grep 'IPv4' | rev | cut -d' ' -f1 | rev)"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep "^10\.0\.*" )"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | head -n1 | rev | cut -d' ' -f1 | rev)"
# Get IP of Windows host
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep -A6 'DockerNAT' | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -n1 )"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '192\.168\.[0-9]*\.[0-9]*' | head -n1 )"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '10\.0\.[0-9]*\.[0-9]*' | head -n1 )"
[ "$Hostip" ] || Hostip="$(ipconfig.exe | rmcr | grep 'IPv4' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | head -n1 )"

verbose "
Subsystem: $Winsubsystem
Expand Down Expand Up @@ -585,14 +587,14 @@ parse_options() {
--display) Newdisplaynumber="${2:-}" ; shift ;;
-g|--gpu) Sharegpu="yes" ;;
-h|--help) usage; finish ;;
--ip) Hostip="${2:-}" ; shift ;;
--no-auth) Xauthentication="no" ;;
--size) Screensize="${2:-}" ; shift ;;
-v|--verbose) Verbose="yes" ;;
--vcxsrv) Xserver="vcxsrv" ;;
--version) echo "runx version $Version"; Exitcode=0 ;;
--xwin) Xserver="xwin" ;;
--) shift; Hostcommand="$@"; break ;;
--ip) Hostip="${2:-}" ; shift ;; #experimental
*) error "Unknown option: ${1:-}
Look at 'runx --help' for valid options."
esac
Expand Down

0 comments on commit 6532ee7

Please sign in to comment.