sh-4.3#
Can anybody tell me where you specify your prompt that works with this method of starting X?
]]>It involves using `runuser -l <user> -c "<command>"`, which allows root (and only root!) to run a command in a full user login session.
To use it requires the presence of a PAM config file, /etc/pam.d/runuser-l, which is currently missing in Arch Linux. (Note: the documentation for util-linux (the owner of /usr/bin/runuser) says that this file must be provided by distributions themselves.)
My suggestion for /etc/pam.d/runuser-l is currently under review for Arch (check FS#37644). On my system it is:
#%PAM-1.0
auth sufficient pam_rootok.so
session include system-login
which is taken almost verbatim from the example in util-linux.
Since the session part of /etc/pam.d/system-login takes care of everything to do with setting up the login session, including systemd seat assignment and ACLs, there is nothing left to do. No need for <user> to be a member of any special groups, no polkit rules, no D-Bus setup, no wrapper scripts, nothing. <command> will run exactly as if <user> had logged in manually and executed it from a shell.
An example service file, xbmc@.service, which I use daily to start XBMC (as user 'xbmc', stripped of all the now redundant group memberships and polkit rules) on my media center PC:
[Unit]
Description=XBMC on %I
Conflicts=getty@%i.service
After=systemd-user-sessions.service getty@%i.service plymouth-quit.service
[Service]
ExecStart=/usr/bin/runuser -l xbmc -c "/usr/bin/startx /usr/bin/xbmc --standalone"
ExecStop=/usr/bin/runuser -l xbmc -c "/usr/bin/pkill xbmc.bin"
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/%I
Restart=always
[Install]
WantedBy=graphical.target
(Note: the TTY stuff is there to avoid the hassle of having to determine the current VT from $XDG_VTNR, which would require a wrapper script for anything which involves starting X)
To use it, do:
# systemctl start xbmc@tty2
and verify it is indeed running in its own session by switching VTs back to your 'regular' DE/WM and doing:
$ loginctl list-sessions
Comments and suggestions are welcome.
]]>Sorry, other way around - it usually works on a warm reboot, but not on a cold boot.
This morning it even failed to start X the first time...
OK, it all seems to work now. I guess the problem with the window manager starting before dbus was caused by some sort of bad upgrade before I tried switching to this method, as it seemed to come right after a couple of system upgrades. When it came right the problem with X sometimes failing to start at all began, and that seems to have been an interaction with the remnants of a previous method of starting X, which I hadn't cleaned out properly.
]]>> You don't need anything from https://wiki.archlinux.org/index.php/Systemd/User, you don't need a sleep in your .xinitrc and it works very reliable.
Not for me it doesn't. It seems it usually works on a cold boot, but not a warm reboot. Whether that's because I have an old slow machine, or run as root, or something else - I don't know.
This means at least one of the following scenarios is the case.
You deviated from my 6-step installation instructions.
My installation instructions are incomplete.
You found a bug.
In the third case, we need to find out what the bug is, exactly.
Is there a particular reason why not use the systemd user bus for the X session?
Users and sessions are different things. Using the user bus as session bus breaks a lot of stuff, the $DISPLAY variable being the most obvious example. There is an ongoing discussion on how to deal with this. Lennart Poettering (lead developer of systemd) has suggested a couple of possible solutions, the second of which is implemented by xlogin.
]]>It seems it usually works on a cold boot, but not a warm reboot.
Sorry, other way around - it usually works on a warm reboot, but not on a cold boot.
This morning it even failed to start X the first time...
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$UID/dbus/user_bus_socket
I remember reading that systemd should export it automatically like $XDG_RUNTIME_DIR, but that was surely before v206...
Edit: One obvious problem is the $DISPLAY variable, previously I solved it by setting it directly in dbus.service, but this may not be ideal. Also there may be other caveats...
]]>Not for me it doesn't. It seems it usually works on a cold boot, but not a warm reboot. Whether that's because I have an old slow machine, or run as root, or something else - I don't know.
]]>I'll try to set it up then, and update the wiki (if you're ok with that).
]]>...a daemon that can be used to make applications wait with starting until XOrg is ready for X11 connections.
It seems that your 'x-daemon' workaround does not consider this case, would you mind to elaborate?
]]>