[PATCH xinit] startx: Pass vtX as long as the user did not specify one

Hans de Goede hdegoede at redhat.com
Mon Apr 7 02:27:20 PDT 2014

Adding vtX to $defaultserverargs means that it will only be added when
the user specifies no server arguments.

This means that doing ie: "startx -- -depth 16" will cause the server to start
on a different vt then just "startx", which does not meat the principle of
least surprise.

Instead always pass the vtX argument, except when the user has specified its
own vtX argument. Note that vtX still only gets added for the default server,
since for ie Xnest or Xephyr it makes no sense.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
 startx.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/startx.cpp b/startx.cpp
index f4a0283..5dafce7 100644
--- a/startx.cpp
+++ b/startx.cpp
@@ -59,6 +59,7 @@ defaultserverargs=""
 #ifdef __APPLE__
@@ -194,7 +195,7 @@ if [ x"$server" = x ]; then
     if expr match "$tty" '^/dev/tty[0-9]\+$' > /dev/null; then
         tty_num=$(echo "$tty" | grep -oE '[0-9]+$')
-        defaultserverargs=${defaultserverargs}" vt"${tty_num}
+        vtarg="vt$tty_num"
@@ -213,6 +214,17 @@ if [ x"$serverargs" = x ]; then
+XCOMM if no vt is specified add vtarg (which may be empty)
+for i in $serverargs; do
+    if expr match "$i" '^vt[0-9]\+$' > /dev/null; then
+        have_vtarg="yes"
+    fi
+if [ "$have_vtarg" = "no" ]; then
+    serverargs="$serverargs $vtarg"
 XCOMM if no display, use default
 if [ x"$display" = x ]; then

More information about the xorg-devel mailing list