Kodi Community Forum

Full Version: Systemd, XBMC, autologin & D-Bus authentication
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just wondering if anyone here had a full systemd setup and XBMC running on it. So far, I have gotten XBMC autologin to work on systemd, but it fails to connect to D-Bus, so I cannot suspend/shutdown/reboot/hibernate.

Arch Linux will somewhere in the future be switching to systemd, so I am migrating my systems, but the D-Bus thing is proving a particular PITA.
So, any takers? Big Grin
I've got two boxes running Arch 32-bit that switched over to systemd a couple weeks ago and I have suspend, resume, reboot and shutdown working (haven't tried Hibernate but it appears on the XBMC shutdown menu). I don't have XBMC running as a systemd service. I set up a service that launches mingetty to autologin (as user xbmc). Based on similar instructions I found somewhere to autolaunch agetty, I created a file called /etc/systemd/system/[email protected]:
Code:
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Getty on %I
Documentation=man:mingetty(8)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=rc-local.service

# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
# getty.target didn't actually pull it in.
Before=getty.target
IgnoreOnIsolate=yes

# On systems without virtual consoles, don't start any getty. (Note
# that serial gettys are covered by [email protected], not this
# unit
ConditionPathExists=/dev/tty0

[Service]
Environment=TERM=linux
# the VT is cleared by TTYVTDisallocate
ExecStart=-/sbin/mingetty --autologin xbmc tty1 linux
Type=simple
Restart=always
RestartSec=0
UtmpIdentifier=%I
TTYPath=/dev/%I
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
KillMode=process
IgnoreSIGPIPE=no

# Unset locale for the console getty since the console has problems
# displaying some internationalized messages.
Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=

# Some login implementations ignore SIGTERM, so we send SIGHUP
# instead, to ensure that login terminates cleanly.
KillSignal=SIGHUP

[Install]
Alias=getty.target.wants/[email protected]
WantedBy=graphical.target

Created the following symlink:
Code:
# ln -s /etc/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]

Then I enabled the service with:
Code:
# systemctl enable [email protected]

I start X from ~/.bashrc:
Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
    logout
fi

and XBMC launches from ~/.xinitrc with:
Code:
exec ck-launch-session /usr/bin/xbmc --standalone &> /dev/null

I tried a few other variations before this worked so hopefully I haven't omitted something.
Wow, thanks. That is one hefty systemd file. I use autologin as well now on the traditional init system, I'll give your stuff a shot.
autostart X as a user is no problem in systemd https://wiki.archlinux.org/index.php/Sys...rvice_file

But automount is still a problem on my setup. Is this kind of thing also handled by dbus?
Just wanna thank you guys.
Now systemd is fun again
If you use lightdm or other DE, you can setup auto-login through it and it will register you with consolekit/policykit/dbus

You can possibly setup xrandr and keyboard layouts with scripts.
ConsoleKit is deprecated. I think you should just use systemd, polkit, upower, udisks. IIRC pm features and automounts for user worked out of the box (Openbox and no DM).
https://wiki.archlinux.org/index.php/Sys...er_systemd
(2012-09-01, 04:17)mrchris Wrote: [ -> ]
Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
    logout
fi


Code:
exec ck-launch-session /usr/bin/xbmc --standalone &> /dev/null

What does the "logout part" do?


ConsoleKit will interefere with systemd-login so it should be:

exec /usr/bin/xbmc-standalone
That's why I leave it to lightdm to autologin to the XBMC session. Lightdm will take care of whatever ck, polkit, d-bus requirements there are and additionally you can setup displays, touchpad, etc with lightdm scripts because it would be harder to do in console before XBMC is started.