Re: Automatic X login without a DM

I'm afraid that went completely over my head. But I think the problem was that I didn't realise I still had to follow the instructions at https://wiki.archlinux.org/index.php/Systemd/User as well. After doing that everything seems to work - except when I start rxvt from my window manager it doesn't use my prompt from /etc/profile. And I'm now finding the extra entries in lxtask annoying - this doesn't really seem worth it, just to get rid of an autologin to tty1

Re: Automatic X login without a DM

Oh dear I also need to put a sleep in .xinitrc before executing anything which needs dbus, otherwise it isn't able to connect. I thought the fix for this might be to tell systemd to start xlogin after dbus.service, but that doesn't work.

Running your .xinitrc should not return, so either have wait as the last command in your .xinitrc, or add exec to the last command that will be called and which should not return (your window manager, for instance).

Re: Automatic X login without a DM

It does. The x-daemon program does the same as xorg-launch-helper but in under 10 lines of Bash. The xlogin@ service orders itself after the x@ service, which finishes as soon as Xorg is ready for X11 connections.

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.

Re: Automatic X login without a DM

Re: Automatic X login without a DM

Alister.Hood wrote:

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.

Re: Automatic X login without a DM

Re: Automatic X login without a DM

I think it is worth mentioning that there is another, much simpler way of starting a user session from a service, and I hope it gets considered for its merit before upstream settles on one choice or the other.

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:

Re: Automatic X login without a DM

I realize that the original problem was about starting X as a specific user, not a fixed user on a specific TTY. This is easy to do by substituting the template variable %I in the appropriate places, but as I don't know of a way to pass multiple values to a systemd service template like: <servicename>@<user>:<tty>.service and then separate them again within the template, the choice currently remains either one or the other.

Re: Automatic X login without a DM

Re: Automatic X login without a DM

Hmmm. I think my problems earlier with X failing to start were somehow related to nouveau driver issues and this method trying to launch X earlier than other methods, as I don't have that problem with the nvidia drivers.But I do still have the problem that I can't figure out how to get my preferred prompt when I launch a terminal from my file manager or my WM/panel. I always get this:

sh-4.3#

Can anybody tell me where you specify your prompt that works with this method of starting X?