Skip to content

Commit

Permalink
--vt [=N]: argument N is optional now #404
Browse files Browse the repository at this point in the history
  • Loading branch information
mviereck committed Dec 31, 2021
1 parent f95db0c commit eb366f1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project website: https://github.com/mviereck/x11docker
- `--backend`: Fallbacks to `podman` and `nerdctl` if `docker` not found.
- `--showenv`,`--showid`,`--showinfofile`,`--showpid1` accept optional
argument FILE to print into a file instead of stdout.
- `--vt [=N]`: Argument N is optional now.
[(#404)](https://github.com/mviereck/x11docker/issues/404)
### Fixed
- `--gpu`: Set environment variables of `prime-run`.
[(#394)](https://github.com/mviereck/x11docker/issues/394)
Expand Down
75 changes: 41 additions & 34 deletions x11docker
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ X and Wayland special configuration:
--keymap=LAYOUT Set keyboard layout for new X server, e.g. de, us, ru.
For possible LAYOUT look at /usr/share/X11/xkb/symbols.
--no-auth Allow access to X for everyone. Security risk!
--vt=N Use vt / tty N (regarded by --xorg only).
--vt [=N] Use vt / tty N. Regarded by --xorg only.
Without N automatically search an unused tty.
--westonini=FILE Custom weston.ini for --weston and --weston-xwayland.
--xhost [=STR] Set \"xhost STR\" on new X server (see 'man xhost').
Without STR will set: +SI:localuser:\$USER
Expand Down Expand Up @@ -2319,10 +2320,16 @@ check_vt() { # option --xorg: find free vt / tty
local Line= Ttyinuse=

# if started from console, use current tty
tty -s && [ "$Runsonconsole" = "yes" ] && {
Newxvt="$(tty | rev | cut -d/ -f1 | rev)"
Newxvt="${Newxvt#tty}"
}
case "$Newxvt" in
"")
tty -s && [ "$Runsonconsole" = "yes" ] && {
Newxvt="$(tty | rev | cut -d/ -f1 | rev)"
Newxvt="${Newxvt#tty}"
}
;;
auto) Newxvt="" ;;
*) return 0 ;;
esac

# check ttys currently in use
[ "$Newxvt" ] || {
Expand Down Expand Up @@ -3146,8 +3153,8 @@ startup-animation=fade
-verbose"
[ "$Xorgconf" ] && Xserveroptions="$Xserveroptions \\
-config '$Xorgconf'" # --xorgconf
[ "$Runsonconsole" = "yes" ] && Xserveroptions="$Xserveroptions \\
-keeptty"
# [ "$Runsonconsole" = "yes" ] && Xserveroptions="$Xserveroptions \\
# -keeptty"
Xcommand="$(command -v Xorg) :$Newdisplaynumber vt$Newxvt $Xserveroptions"
;;

Expand Down Expand Up @@ -8666,32 +8673,32 @@ stdout() {
parse_options() { # parse cli options
local Shortoptions Longoptions Parsedoptions Presetoptions Presetfile
Shortoptions="aAcdDefFghHiIKlmnpPqtTvVwWxXyY"
Longoptions="exe,xonly" # Alternate setups of x11docker
Longoptions="$Longoptions,auto,desktop,tty,wayland,wm::" # Influencing auto-setup of X/Wayland/x11docker
Longoptions="$Longoptions,hostdisplay,nxagent,runx,xdummy,xephyr,xpra,xorg,xvfb,xwin" # X servers
Longoptions="$Longoptions,kwin-xwayland,weston-xwayland,xpra-xwayland,xwayland" # X servers depending on a Wayland compositor
Longoptions="$Longoptions,hostwayland,kwin,weston" # Wayland compositors without X
Longoptions="$Longoptions,border::,dpi:,fullscreen,output-count:,rotate:,scale:,size:,xfishtank" # X/Wayland appearance options
Longoptions="$Longoptions,clean-xhost,composite::,display:,iglx,keymap:,no-auth,vt:,westonini:,xhost::,xoverip,xtest::" # X/Wayland config
Longoptions="$Longoptions,enforce-i,fallback::,preset:,pull::,pw::" # x11docker config
Longoptions="$Longoptions,cachebasedir:,home::,homebasedir:,share:" # Host folders
Longoptions="$Longoptions,alsa::,clipboard,gpu,lang::,printer::,pulseaudio::,webcam" # Host integration features
Longoptions="$Longoptions,backend:,env:,mobyvm,name:,no-entrypoint,runtime:,snap,workdir:" # Container config
Longoptions="$Longoptions,cap-default,hostipc,limit::,newprivileges::,network::" # Container capabilities
Longoptions="$Longoptions,group-add:,hostuser:,password::,sudouser::,user:,shell:" # Container user
Longoptions="$Longoptions,dbus::,init::,hostdbus,sharecgroup" # Container init and DBus
Longoptions="$Longoptions,stdin,interactive" # Container interaction
Longoptions="$Longoptions,runasuser:,runfromhost:,runasroot:" # Additional commands to execute
Longoptions="$Longoptions,printenv::,printid::,printinfofile::,printpid1::" # Output of vars on stdout
Longoptions="$Longoptions,debug,quiet,verbose" # Verbose options
Longoptions="$Longoptions,build,cleanup,help,launcher,licence,license,version" # Special options without starting X or container
Longoptions="$Longoptions,install,remove,update,update-master" # Installation
Longoptions="exe,xonly" # Alternate setups of x11docker
Longoptions="$Longoptions,auto,desktop,tty,wayland,wm::" # Influencing auto-setup of X/Wayland/x11docker
Longoptions="$Longoptions,hostdisplay,nxagent,runx,xdummy,xephyr,xpra,xorg,xvfb,xwin" # X servers
Longoptions="$Longoptions,kwin-xwayland,weston-xwayland,xpra-xwayland,xwayland" # X servers depending on a Wayland compositor
Longoptions="$Longoptions,hostwayland,kwin,weston" # Wayland compositors without X
Longoptions="$Longoptions,border::,dpi:,fullscreen,output-count:,rotate:,scale:,size:,xfishtank" # X/Wayland appearance options
Longoptions="$Longoptions,clean-xhost,composite::,display:,iglx,keymap:,no-auth,vt::,westonini:,xhost::,xoverip,xtest::" # X/Wayland config
Longoptions="$Longoptions,enforce-i,fallback::,preset:,pull::,pw::" # x11docker config
Longoptions="$Longoptions,cachebasedir:,home::,homebasedir:,share:" # Host folders
Longoptions="$Longoptions,alsa::,clipboard,gpu,lang::,printer::,pulseaudio::,webcam" # Host integration features
Longoptions="$Longoptions,backend:,env:,mobyvm,name:,no-entrypoint,runtime:,snap,workdir:" # Container config
Longoptions="$Longoptions,cap-default,hostipc,limit::,newprivileges::,network::" # Container capabilities
Longoptions="$Longoptions,group-add:,hostuser:,password::,sudouser::,user:,shell:" # Container user
Longoptions="$Longoptions,dbus::,init::,hostdbus,sharecgroup" # Container init and DBus
Longoptions="$Longoptions,stdin,interactive" # Container interaction
Longoptions="$Longoptions,runasuser:,runfromhost:,runasroot:" # Additional commands to execute
Longoptions="$Longoptions,printenv::,printid::,printinfofile::,printpid1::" # Output of vars on stdout
Longoptions="$Longoptions,debug,quiet,verbose" # Verbose options
Longoptions="$Longoptions,build,cleanup,help,launcher,licence,license,version" # Special options without starting X or container
Longoptions="$Longoptions,install,remove,update,update-master" # Installation
#
Longoptions="$Longoptions,keepcache,no-setup,xopt:,xorgconf:" # Experimental
Longoptions="$Longoptions,dbus-system,homedir:,hostnet,no-internet,no-xhost,sharedir:,sharessh,systemd" # Deprecated
Longoptions="$Longoptions,showenv,showid,showinfofile,showpid1" # Deprecated
Longoptions="$Longoptions,cachedir:,no-init,nothing,no-xtest,openrc,podman,pull:,ps,runit,silent,starter" # Removed
Longoptions="$Longoptions,stderr,stdout,sys-admin,sysvinit,tini,trusted,untrusted,vcxsrv" # Removed
Longoptions="$Longoptions,keepcache,no-setup,xopt:,xorgconf:" # Experimental
Longoptions="$Longoptions,dbus-system,homedir:,hostnet,no-internet,no-xhost,sharedir:,sharessh,systemd" # Deprecated
Longoptions="$Longoptions,showenv,showid,showinfofile,showpid1" # Deprecated
Longoptions="$Longoptions,cachedir:,no-init,nothing,no-xtest,openrc,podman,pull:,ps,runit,silent,starter" # Removed
Longoptions="$Longoptions,stderr,stdout,sys-admin,sysvinit,tini,trusted,untrusted,vcxsrv" # Removed

Parsedoptions="$(getopt --options "$Shortoptions" --longoptions "$Longoptions" --name "$0" -- "$@" )" || error "Failed to parse options."
eval set -- "$Parsedoptions"
Expand Down Expand Up @@ -8800,7 +8807,7 @@ parse_options() { # parse cli options
shift ;;
--iglx) Iglx="yes" ;; # Indirect rendering; broken since Xorg ~18.2 except with closed NVIDIA. libgl needs a fix.
--keymap) Xkblayout="${2:-}" ; shift ;; # Keymap layout for xkbcomp. Compare /usr/share/X11/xkb/symbols
--vt) Newxvt="${2:-}" ; shift ;; # Virtual console to use for --xorg
--vt) Newxvt="${2:-auto}" ; shift ;; # Virtual console to use for --xorg
--xoverip) Xoverip="yes" ;; # Use X over TCP/IP instead of sharing X socket
--xtest) case "${2:-}" in # X extension XTEST
yes|"") Xtest="yes" ;;
Expand Down Expand Up @@ -9098,7 +9105,7 @@ Parsed options: $Parsedoptions_global"

#### Create command to run X server [and/or Wayland compositor]
[ "$Xserver" != "--xorg" ] && [ -n "$Newxvt" ] && note "Option --vt only takes effect with option --xorg."
[ "$Xserver" = "--xorg" ] && [ -z "$Newxvt" ] && check_vt # --vt: find free tty/virtual terminal for Xorg
[ "$Xserver" = "--xorg" ] && check_vt # --vt: find free tty/virtual terminal for Xorg
{ [ "$Xserver" = "--xdummy" ] || [ "$Xpravfb" = "Xdummy" ] ; } && {
create_xdummyxorgconf >> "$Xdummyconf"
create_xdummywrapper >> "$Xorgwrapper"
Expand Down

0 comments on commit eb366f1

Please sign in to comment.