translating---geekpi

Starting user software in X
======

There are currently many ways of starting software when a user session starts.

This is an attempt to collect a list of pointers to piece the big picture together. It's partial and some parts might be imprecise or incorrect, but it's a start, and I'm happy to keep it updated if I receive corrections.

### x11-common

`man xsession`

  * Started by the display manager for example, `/usr/share/lightdm/lightdm.conf.d/01_debian.conf` or `/etc/gdm3/Xsession`
  * Debian specific
  * Runs scripts in `/etc/X11/Xsession.d/`
  * `/etc/X11/Xsession.d/40x11-common_xsessionrc` sources `~/.xsessionrc` which can do little more than set env vars, because it is run at the beginning of X session startup
  * At the end, it starts the session manager (`gnome-session`, `xfce4-session`, and so on)



### systemd --user

  * <https://wiki.archlinux.org/index.php/Systemd/User>
  * Started by `pam_systemd`, so it might not have a DISPLAY variable set in the environment yet
  * Manages units in:
    * `/usr/lib/systemd/user/` where units provided by installed packages belong.
    * `~/.local/share/systemd/user/` where units of packages that have been installed in the home directory belong.
    * `/etc/systemd/user/` where system-wide user units are placed by the system administrator.
    * `~/.config/systemd/user/` where the users put their own units.
  * A trick to start a systemd user unit when the X session has been set up and the DISPLAY variable is available, is to call `systemctl start` from a `.desktop` autostart file.



### dbus activation

  * <https://dbus.freedesktop.org/doc/system-activation.txt>
  * A user process making a dbus request can trigger starting a server program
  * For systems debugging, is there a way of monitoring what services are getting dbus activated?



### X session manager

  * <https://en.wikipedia.org/wiki/X_session_manager>
  * Run by `x11-common`'s `Xsession.d`
  * Runs freedesktop autostart .desktop files
  * Runs Desktop Environment specific software



### xdg autostart

  * <https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html>
  * Run by the session manager
  * If `/etc/xdg/autostart/foo.desktop` and `~/.config/autostart/foo.desktop` exist then only the file `~/.config/autostart/foo.desktop` will be used because `~/.config/autostart/` is more important than `/etc/xdg/autostart/`
  * Is there an ordering or is it all in parallel?



### Other startup notes

#### ~/.Xauthority

To connect to an X server, a client needs to send a token from `~/.Xauthority`, which proves that they can read the user's provate data.

`~/.Xauthority` contains a token generated by display manager and communicated to X at startup.

To view its contents, use `xauth -i -f ~/.Xauthority list`

--------------------------------------------------------------------------------

via: http://www.enricozini.org/blog/2018/debian/starting-user-software/

作者:[Enrico Zini][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)

本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

[a]:http://www.enricozini.org/