Xprofile: Difference between revisions

From ArchWiki
m (add the Chinese page)
(Remove mention of KDM and SLiM, it's a long time they are outdated and not maintained.)
 
(15 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Lowercase title}}
{{Lowercase title}}
[[Category:X Server]]
[[Category:X server]]
[[es:Xprofile]]
[[es:Xprofile]]
[[ja:Xprofile]]
[[ja:Xprofile]]
[[pt:Xprofile]]
[[ru:Xprofile]]
[[ru:Xprofile]]
[[zh-CN:Xprofile]]
[[zh-hans:Xprofile]]
{{Related articles start}}
{{Related articles start}}
{{Related|xinitrc}}
{{Related|xinitrc}}
{{Related articles end}}
{{Related articles end}}


An xprofile file, {{ic|~/.xprofile}} and {{ic|/etc/xprofile}}, allows you to execute commands at the beginning of the X user session - before the [[Window manager]] is started. Xprofile is of particular use for autostarting programs with a session, started from a [[Display manager]], when that session does not have its own autostart facility - a standalone [[Window manager]] for example.
An xprofile file, {{ic|~/.xprofile}} and {{ic|/etc/xprofile}}, allows you to execute commands at the beginning of the X user session - before the [[window manager]] is started.


The xprofile file is similar in syntax and in concept to [[xinitrc]], {{ic|~/.xinitrc}} and {{ic|/etc/X11/xinit/xinitrc.d/}}.
The xprofile file is similar in style to [[xinitrc]].


== Compatibility ==
== Compatibility ==


The xprofile and [[xinitrc]] files are natively sourced by the following display managers:
The xprofile files are natively sourced by the following display managers:
* [[GDM]] - {{ic|/etc/gdm/Xsession}}
* [[GDM]] - {{ic|/etc/gdm/Xsession}}
* [[KDM]] - {{ic|/usr/share/config/kdm/Xsession}}
* [[LightDM]] - {{ic|/etc/lightdm/Xsession}}
* [[LightDM]] - {{ic|/etc/lightdm/Xsession}}
* [[LXDM]] - {{ic|/etc/lxdm/Xsession}}
* [[LXDM]] - {{ic|/etc/lxdm/Xsession}}
* [[SDDM]] - {{ic|/usr/share/sddm/scripts/Xsession}}


=== Sourcing xprofile from a session started with xinit ===
=== Sourcing xprofile from a session started with xinit ===


It is possible to source xprofile from a session started with one of the following programs:
It is possible to source xprofile from a session started with one of the following programs:
* {{ic|startx}}
* {{ic|startx}}
* {{ic|xinit}}
* {{ic|xinit}}
* [[XDM]]
* [[XDM]]
* [[SLiM]]
* Any other [[Display manager]] which uses {{ic|~/.xsession}} or {{ic|~/.xinitrc}}
* Any other [[Display manager]] which uses {{ic|~/.xsession}} or {{ic|~/.xinitrc}}


All of these execute, directly or indirectly, {{ic|~/.xinitrc}} (usually copied from {{ic|/etc/skel/.xinitrc}}), or {{ic|/etc/X11/xinit/xinitrc}} if it does not exist. That is why we have to source xprofile from these files.
All of these execute, directly or indirectly, {{ic|~/.xinitrc}} or {{ic|/etc/X11/xinit/xinitrc}} if it does not exist. That is why xprofile has to be sourced from these files.


{{hc|~/.xinitrc and /etc/X11/xinit/xinitrc and /etc/skel/.xinitrc|
{{hc|~/.xinitrc and /etc/X11/xinit/xinitrc|
#!/bin/sh
#!/bin/sh


# Make sure this is before the 'exec' command or it won't be sourced.
# Make sure this is before the 'exec' command or it won't be sourced.
[ -f /etc/xprofile ] && source /etc/xprofile
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && source ~/.xprofile
[ -f ~/.xprofile ] && . ~/.xprofile


...
...
}}
}}
{{ic|xinitrc.d/*}} files are already sourced from the default xinitrc file.


== Configuration ==
== Configuration ==


Firstly, create the file {{ic|~/.xprofile}} if it does not exist already. Then, simply add the commands for the programs you wish to start with the session. See below:
Firstly, create the file {{ic|~/.xprofile}} if it does not exist already. Then, simply add the commands for the programs you wish to start with the session. See below:
{{hc|~/.xprofile|
{{hc|~/.xprofile|
tint2 &
tint2 &
nm-applet &
nm-applet &
}}
}}

Latest revision as of 13:55, 7 September 2018

An xprofile file, ~/.xprofile and /etc/xprofile, allows you to execute commands at the beginning of the X user session - before the window manager is started.

The xprofile file is similar in style to xinitrc.

Compatibility

The xprofile files are natively sourced by the following display managers:

  • GDM - /etc/gdm/Xsession
  • LightDM - /etc/lightdm/Xsession
  • LXDM - /etc/lxdm/Xsession
  • SDDM - /usr/share/sddm/scripts/Xsession

Sourcing xprofile from a session started with xinit

It is possible to source xprofile from a session started with one of the following programs:

All of these execute, directly or indirectly, ~/.xinitrc or /etc/X11/xinit/xinitrc if it does not exist. That is why xprofile has to be sourced from these files.

~/.xinitrc and /etc/X11/xinit/xinitrc
#!/bin/sh

# Make sure this is before the 'exec' command or it won't be sourced.
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && . ~/.xprofile

...

Configuration

Firstly, create the file ~/.xprofile if it does not exist already. Then, simply add the commands for the programs you wish to start with the session. See below:

~/.xprofile
tint2 &
nm-applet &