[systemd-devel] systemctl user start Xorg

arnaud gaboury arnaud.gaboury at gmail.com
Thu Oct 30 04:20:18 PDT 2014


Archlinux 3.16.3
systemd 216-3
startx at login prompt. No DM


I am slowly trying to use systemctl --user facilities.
Until now, I am able to start few basic user services. Now it is time
to start Xorg as a user service, but I can't manage to do it. As
documentation is currently very sparse, I must admit I am a little
lost when it comes to write the unit files. I can't even know if it is
feasible.

I have tried all kinds of things in my xorg.service file. Below are
two ways among others.
---------------------------------------
[Unit]
Description=Xorg server at display :0
Requires=xorg.socket
After=xorg.socket

[Service]
# ExecStart=/usr/bin/Xorg.bin -nolisten tcp vt$XDG_VTNR
 ExecStart=/usr/bin/xinit -- :0 -nolisten tcp vt$XDG_VTNR
----------------------------------

Results are usually failed status. Here are some logs:
-----------------------------------
● xorg.service - Xorg server at display :0
   Loaded: loaded (/home/gabx/.config/systemd/user/xorg.service; static)
   Active: failed (Result: exit-code) since Thu 2014-10-30 10:22:34 CET; 39s ago
  Process: 11792 ExecStart=/usr/bin/Xorg.bin -nolisten tcp vt$XDG_VTNR
(code=exited, status=1/FAILURE)
 Main PID: 11792 (code=exited, status=1/FAILURE)

Oct 30 10:22:34 hortensia systemd[850]: Started Xorg server at display :0.
Oct 30 10:22:34 hortensia Xorg.bin[11792]: use: X [:<display>] [option]
Oct 30 10:22:34 hortensia Xorg.bin[11792]: -a #
default pointer acceleration (factor)
Oct 30 10:22:34 hortensia Xorg.bin[11792]: -ac
disable access control restrictions
Oct 30 10:22:34 hortensia systemd[850]: xorg.service: main process
exited, code=exited, status=1/FAILURE
Oct 30 10:22:34 hortensia systemd[850]: Unit xorg.service entered failed state.
-----------------------------------------------------------
● xorg.service - Xorg server at display :0
   Loaded: loaded (/home/gabx/.config/systemd/user/xorg.service; static)
   Active: failed (Result: exit-code) since Thu 2014-10-30 10:42:17
CET; 1min 8s ago
  Process: 12191 ExecStart=/usr/bin/xinit -- :0 -nolisten tcp
vt$XDG_VTNR (code=exited, status=1/FAILURE)
 Main PID: 12191 (code=exited, status=1/FAILURE)

Oct 30 10:42:02 hortensia systemd[850]: Started Xorg server at display :0.
Oct 30 10:42:02 hortensia xinit[12191]: /usr/bin/Xorg.wrap: Only
console users are allowed to run the X server
Oct 30 10:42:17 hortensia systemd[850]: xorg.service: main process
exited, code=exited, status=1/FAILURE
Oct 30 10:42:17 hortensia systemd[850]: Unit xorg.service entered failed state.
-----------------------------------------------------------

I even tried to set $XDG_VTNR variable this way:
$ systemctl --user set-environment XDG_VTNR=1



Some info about my system:
------------------------
gabx at hortensia ➤➤ ~ % systemctl --user status
● hortensia
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Thu 2014-10-30 11:09:46 CET; 18min ago
   CGroup: /user.slice/user-1000.slice/user at 1000.service
           ├─852 /usr/lib/systemd/systemd --user
           ├─853 (sd-pam)
           ├─dbus.service
           │ └─2238 /usr/bin/dbus-daemon --session --address=systemd:
--nofork --systemd-activation
           ├─tmux.service
           │ ├─900 /usr/bin/tmux new-session -d -n irc irssi && zsh
           │ ├─901 zsh -c irssi && zsh
           │ └─906 irssi
           ├─urxvtd.service
           │ └─1394 /usr/bin/urxvtd -o -q -f
           ├─gpg-agent.service
           │ └─898 /usr/bin/gpg-agent --homedir
/home/gabx/.config/gnupg --daemon --write-env-file
/home/gabx/.config/gnupg/gpg-agent.info
           └/home/g─ssh-agent.service
             └─892 /usr/bin/ssh-agent -d -a /run/user/1000/ssh_auth_sock
-------------------------------------------------
gabx at hortensia ➤➤ ~ % systemctl --user show-environment
DISPLAY=:0
HOME=/home/gabx
LANG=en_US.UTF-8
LC_COLLATE=C
LOGNAME=gabx
MAIL=/var/spool/mail/gabx
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SHELL=/usr/bin/zsh
USER=gabx
XDG_RUNTIME_DIR=/run/user/1000
----------------------------------------------------------
gabx at hortensia ➤➤ ~ % systemd-cgls
├─1 /usr/lib/systemd/systemd
├─system.slice
│ ├─dbus.service
│ │ └─608 /usr/bin/dbus-daemon --system --address=systemd: --nofork
--nopidfile --systemd-activation
│ ├─lvm2-lvmetad.service
│ │ └─365 /usr/bin/lvmetad -f
│ ├─systemd-machined.service
│ │ └─843 /usr/lib/systemd/systemd-machined
│ ├─mysqld.service
│ │ └─519 /usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid
│ ├─adb.service
│ │ └─583 adb -P 5037 fork-server server
│ ├─systemd-journald.service
│ │ └─200 /usr/lib/systemd/systemd-journald
│ ├─system-devmon.slice
│ │ └─devmon at gabx.service
│ │   ├─ 549 /bin/bash /usr/bin/devmon
│ │   └─1098 /usr/sbin/udevil --monitor
│ ├─udisks2.service
│ │ └─2202 /usr/lib/udisks2/udisksd --no-debug
│ ├─systemd-timesyncd.service
│ │ └─463 /usr/lib/systemd/systemd-timesyncd
│ ├─systemd-logind.service
│ │ └─590 /usr/lib/systemd/systemd-logind
│ ├─systemd-networkd.service
│ │ └─675 /usr/lib/systemd/systemd-networkd
│ ├─systemd-udevd.service
│ │ └─229 /usr/lib/systemd/systemd-udevd
│ ├─system-systemd\x2dnspawn.slice
│ │ └─systemd-nspawn at dahlia.service
│ │   ├─471 /usr/bin/systemd-nspawn --quiet --keep-unit --boot
--link-journal=guest --directory=/var/lib/container/dahlia
│ │   ├─472 /usr/lib/systemd/systemd
│ │   └─system.slice
│ │     ├─dbus.service
│ │     │ └─896 /usr/bin/dbus-daemon --system --address=systemd:
--nofork --nopidfile --systemd-activation
│ │     ├─systemd-journald.service
│ │     │ └─870 /usr/lib/systemd/systemd-journald
│ │     ├─systemd-logind.service
│ │     │ └─904 /usr/lib/systemd/systemd-logind
│ │     └─console-getty.service
│ │       └─905 /sbin/agetty --noclear --keep-baud console 115200
38400 9600 vt102
│ ├─polkit.service
│ │ └─2206 /usr/lib/polkit-1/polkitd --no-debug
│ ├─bitlbee.service
│ │ └─498 /usr/bin/bitlbee -F -n
│ ├─acpid.service
│ │ └─473 /usr/bin/acpid -f
│ └─rtkit-daemon.service
│   └─2283 /usr/lib/rtkit/rtkit-daemon
└─user.slice
  └─user-1000.slice
    ├─user at 1000.service
    │ ├─852 /usr/lib/systemd/systemd --user
    │ ├─853 (sd-pam)
    │ ├─dbus.service
    │ │ └─2238 /usr/bin/dbus-daemon --session --address=systemd:
--nofork --systemd-activation
    │ ├─tmux.service
    │ │ ├─900 /usr/bin/tmux new-session -d -n irc irssi && zsh
    │ │ ├─901 zsh -c irssi && zsh
    │ │ └─906 irssi
    │ ├─urxvtd.service
    │ │ └─1394 /usr/bin/urxvtd -o -q -f
    │ ├─gpg-agent.service
    │ │ └─898 /usr/bin/gpg-agent --homedir /home/gabx/.config/gnupg
--daemon --write-env-file /home/gabx/.config/gnupg/gpg-agent.info
    │ └─ssh-agent.service
    │   └─892 /usr/bin/ssh-agent -d -a /run/user/1000/ssh_auth_sock
    └─session-3.scope
      ├─1657 login -- gabx
      ├─1661 -zsh
      ├─1914 /bin/sh /usr/bin/startx
      ├─1936 xinit /home/gabx/.xinitrc -- /etc/X11/xinit/xserverrc :0
vt1 -auth /tmp/serverauth.x9Owrz1L2n
      ├─1937 /usr/bin/Xorg.bin -nolisten tcp :0 vt1 -auth
/tmp/serverauth.x9Owrz1L2n vt1
      ├─1941 i3
      ├─1960 i3bar --bar_id=bar-0 --socket=/run/user/1000/i3/ipc-socket.1941
      ├─1963 kalu
      ├─1965 firefox
      ├─1966 urxvt
      ├─1970 urxvt
      ├─1972 caja --no-desktop
      ├─1979 /usr/bin/dbus-launch --autolaunch
77f348a2b3fb429b85a5de751ea9175a --binary-syntax --close-stderr
      ├─1980 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address
7 --session
      ├─1982 /usr/lib/at-spi2-core/at-spi-bus-launcher
      ├─1987 i3status --config=~/.config/i3/i3status.conf
      ├─1988 /usr/bin/dbus-daemon
--config-file=/etc/at-spi2/accessibility.conf --nofork --print-address
3
      ├─2004 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
      ├─2015 zsh
      ├─2018 zsh
      ├─2026 /usr/lib/dconf/dconf-service
      ├─2068 /usr/bin/dunst
      ├─2177 /usr/lib/gvfs/gvfsd
      ├─2181 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
      ├─2200 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
      ├─2218 /usr/lib/gvfs/gvfs-afc-volume-monitor
      ├─2232 /usr/lib/gvfs/gvfsd-metadata
      ├─2282 /usr/bin/pulseaudio --start --log-target=syslog
      ├─2411 systemd-cgls
      └─2412 less
---------------------------
gabx at hortensia ➤➤ ~ % cat /etc/pam.d/system-login
#%PAM-1.0

auth       required   pam_tally.so         onerr=succeed file=/var/log/faillog
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       include    system-auth
# for ssh authentification
# auth       optional   pam_exec.so    expose_authtok
/etc/scripts/systemd-user-pam-ssh

account    required   pam_access.so
account    required   pam_nologin.so
account    include    system-auth

password   include    system-auth

session    optional   pam_loginuid.so
session    include    system-auth
session    optional   pam_motd.so          motd=/etc/motd
session    optional   pam_mail.so          dir=/var/spool/mail standard quiet
# loaded now from system-auth
-session   optional   pam_systemd.so
#session    required   pam_env.so
--------------------------------------------------------
gabx at hortensia ➤➤ ~ % cat /etc/pam.d/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.

account  include system-login
session  include system-login
------------------------------------------------------
gabx at hortensia ➤➤ ~ % cat .xinitrc
xset fp rehash &
# load my X resources
xrdb -merge $HOME/.config/urxvt/.urxvtrc &

# start desktop environment
exec i3
-------------------------------------------
gabx at hortensia ➤➤ ~ % cat /etc/X11/xinit/xserverrc
#!/bin/sh

if [ -z "$XDG_VTNR" ]; then
  exec /usr/bin/X -nolisten tcp "$@"
else
  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
fi
-----------------------------------------


Any help/hint/pointer would be appreciate. Thank you in advance.


More information about the systemd-devel mailing list