1

My requirement is a little different from this one in that I would like to launch a window manager for each of two non-root users upon boot.

For testing, first I prepare the following lines in .xinitrc and/or .xsession in home directories of user2 and user3 like so:

#!/bin/sh
exec icewm

Then I manually login to virtual console as user2 or user3 or open an xterm window and type this command:

xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

This does the job - icewm and Xvfb run behind the scene.

Now I want to automate the login and command xinit on boot. However none of the following approaches work:

Either manually type these two commands as root or place them in /etc/rc.local:

su -l user2 -c xinit -- /usr/bin/Xvfb :3 -cc 4 -screen 0 1024x768x16

No protocol specified
IceWM: Can't open display: :0. X must be running and $DISPLAY set.

start-stop-daemon --start -u user2 -g user2 -b --pidfile /tmp/pid --exec /usr/bin/xinit -- -- Xvfb :3
ps ax

[Xorg] <defunct>

Helps will be greatly appreciated!

[Edit after testing alex.d.'s approach]

File /home/user2/.xsession:

#!/bin/bash
export DISPLAY=localhost:3
export XAUTHORITY=$HOME/.Xauthority
exec icewm

Issue this command as root:

su -l user2 -c /usr/bin/startx -- /usr/bin/Xvfb :3 &

I get this:

hostname: Name or service not known
xauth: (stdin):1:  bad display name "example.com:2" in "add" command

IceWM: Can't open display: localhost:3. X must be running and $DISPLAY set.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
xauth: (argv):1:  bad display name "example.com:2" in "remove" command

Any idea? Please!

Masa O
  • 41
  • 1
  • 7

2 Answers2

3

This is my working approach.

file /etc/systemd/system/john.service:

[Unit]
Description=xinit - user "john"

[Service]
User=john
Group=john
ExecStart=/usr/bin/xinit openbox-session -- /usr/bin/Xvfb :1 -nolisten tcp
ExecStopPost=/usr/bin/killall -u john

[Install]
WantedBy=multi-user.target

file /home/john/.config/openbox/autostart:

wine my_program.exe

Thank you all for the helps!

Masa O
  • 41
  • 1
  • 7
0

When starting X11 from rc.local, it's not started from inside a user session (consolekit or logind), so things are missing in the environment. Instead of a bare xinit, you should try to start X11 with startx which is intended to start a session.

alex.d.
  • 11
  • 1
  • I have just used *startx* instead and edited to show issues coming with that script. – Masa O May 27 '16 at 09:34
  • Why do you explicitely force values for $DISPLAY and $XAUTHORITY? In particular, DISPLAY=localhost:3 will work only if X is listenning on TCP sockets. It should be DISPLAY=:3 (or better: do not set it, startx will do it for you). And why force a value for XAUTHORITY? Especially if you do it in the .Xsession, it's to late and you lose the value set by startx. – alex.d. May 30 '16 at 09:22