Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using xorg and vt multiscreen, no multiseat, one keyboard.
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 30 Aug 2015
Posts: 36

PostPosted: Sun Aug 30, 2015 5:48 pm    Post subject: Using xorg and vt multiscreen, no multiseat, one keyboard. Reply with quote

This has been bothering me since my first matrox-dualhead card, and I never found a solution:

If you want to use more than one monitor on Linux you are practically forced forget about the vt-console. Unless you want a myriad of mice and keyboards on your desk.

The problem is that for X got two options of how to coexist with the console. And neither are practically usable in a single-user multi-monitor environment.
Option one: X lives in a VT; This makes the picture on the monitor handling the console freeze when X is active. And gives you a black screen on the X monitor when the console is active.
Option two: Start X with
-novtswicth -sharevts
; Now all screens are active all the time. But all keyboard and mouse input is duplicated to both the console and X, which makes it useless.

Then you have the choice of putting option
"GrabDevice" "true"
in Section "InputDevice" of xorg.conf or equivalent, witch require one keyboard/mouse set for each monitor and is made for multiseat.

Since I've not been able at find a solution in all these years, I had to make one. For the same reason, and even-tough I really can't code I felt that I should post it somewhere when I finally had a working solution.

What i did was use the source of evemu-2.2.0.tar.xz from portage, and molested it till I had a working virtual input switch.
It takes an event device from /dev/input/ and, two or three device descriptor files from evemu-describe as input. It grabs the input from the real device and creates two or three virtual input-devices witch you can switch the output between.
It is controlled by sending ascii 1,2 or 3 to the fifo device at /dev/input/eventX_control where X is the number of the real event device you used as input.

The patch against evemu-2.2.0 is posted at
It has a issue that it segfauls when interrupted by ctrl-c, but if you need this you will probably not be quitting it unless reboot.
Else the routine for reading the control input does not work how i planned, it seems to require a newline after each command. And I think it ignores the first command sent after starting. But it does the job, while spamming nonsense to the error log. You might want to clean up the logging code if you gonna use this.

Quick usage instructions:
Make descriptor files from your mouse and keyboard with evemu-describe. Make one copy for each emulated device, and change the line beginning with "N:" in each file to give the devices individual names.

Edit the following to your preference and put in /etc/init.d/evswitch:
# Distributed under the terms of the GNU General Public License v2
# $Id$

#This is for using VT-Console and Xorg in concurrent multiscreen
#(xorg started with "-novtswitch -sharevts") in a single user enviroment. With
#only one mouse and keyboard switchable between xorg and the VT termainals.
#Every instance of evemu-switch makes a named fifo at by appending "_control"
#to the full path of the original event device. The switching is conntrolled
#by sending sending a text file with the number of the wanated output to this
#The simplest way of controling is making two text files, one containing the
#character "1" and a newline, the other containing the character "2" and a
#newline. And use "cat yourfile>/dev/input/eventX_control" to switch,
#alternating myfile between the two files.
#The newline is required for the same reason that it might not react to the
#first switch command, I tried to make it read only single characters but
#could not quite nail it.
#I use two of the G-keys on my Corsair K95 to start the cat command for
#switching, wich explains the "need ckb-daemon"
depend() {
   need ckb-daemon

start() {
evdevkb=/dev/input/`cat /proc/bus/input/devices | awk "/$orgkbname/ "'{for(a=0;a>=0;a++){getline;{if(/kbd/==1){ for (i=1; i<=NF; i++)if ($i ~ /event*/)print $i;exit 0;}}}}'`
evdevmouse=/dev/input/`cat /proc/bus/input/devices | awk "/$orgmousename/ "'{for(a=0;a>=0;a++){getline;{if(/mouse/==1){ for (i=1; i<=NF; i++)if ($i ~ /event*/)print $i;exit 0;}}}}'`

ebegin "Starting ${SVCNAME}"
start-stop-daemon -Sbmp /run/ --stdout /var/log/vkb.log --stderr /var/log/vkb_err.log -x /path/to/evemu-switch -- \
                                                                         ${evdevkb} ${kbdescriptor1} ${kbdescriptor2}
start-stop-daemon -Sbmp /run/ --stdout /var/log/vmouse.log --stderr /var/log/vmouse_err.log -x /path/to/evemu-switch -- \
                                                                         ${evdevmouse} ${mousedescriptor1} ${mousedescriptor2}
eend $?

stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon -Kp /run/ -x /path/to/evemu-switch
start-stop-daemon -Kp /run/ -x /path/to/evemu-switch
eend $?

Adjust the the names and paths(here you use the descriptor files you created at the start) of the following to match your setup and put in /etc/conf.d/evswitch:
#Name or identifying-part of name of the original deveices to grab. Names can
#be found by issung 'cat /proc/bus/input/devices'

#Path to descriptor files made with evemu-describe. Using separate files
#edited with individual device names (the "N:" field not the comment
#line "# Input device name:") is reccomended

Set up a way to send commands to the fifo files when you want to switch between X and console. If you initiate the switch from one of the input devises that are switched use a bat file to delay the actual switch (you do not want to switch between a key-press and key-release)

Set up X to grab one set of of the emulated input devices devices.
I use this in /etc/udev/rules.d/99-multixinput.rules:
SUBSYSTEM=="input", ATTRS{name}=="K95xorg", ENV{ID_INPUT.tags}="input_intel"
SUBSYSTEM=="input", ATTRS{name}=="KensongtonXorg", ENV{ID_INPUT.tags}="input_intel"

And this addition to xorg.conf:
Section "InputClass"
        Identifier              "ignore_other_seats"
        Option "Ignore"         "yes"

Section "InputClass"
   Identifier      "input_intel"
   MatchTag      "input_intel"
   Option "Ignore"      "no"
   Option "GrabDevice"   "true"

Start X with "-sharevts -novtswitch" and you can switch input from mouse and keyboard between X and the VT terminals by sending "1" or "2" to the respective fifo control devices.

For a better explanation of the X setup google "xorg multiseat"

PS.: Please ignore the error(WARNING's and some of the fprint errors and comments. I had to post this while it was working and before my adhd-attention-span shifted to something else.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum