Difference between revisions of "Autostarting"

From ArchWiki
Jump to: navigation, search
(Shells)
(Graphical)
Line 39: Line 39:
 
=== X session startup ===
 
=== X session startup ===
  
See [[xinitrc]] and [[xprofile]].
+
See [[xinitrc|~/.xinitrc]] and [[xprofile|~/.xprofile and /etc/xprofile]].
  
 
=== X Desktop Group ===
 
=== X Desktop Group ===
  
{{ic|$XDG_CONFIG_DIRS/autostart/}}: In this folder are {{ic|.desktop}} files. These files determine which programs are loaded for which desktop environment. For an explanation of the desktop file standard refer to [http://standards.freedesktop.org/desktop-entry-spec/latest/ Desktop Entry Specification].
+
* {{ic|/etc/xdg/autostart}}: The folder contains {{ic|*.desktop}} files, which will be executed everytime an X session starts.
 +
* {{ic|$XDG_CONFIG_HOME/autostart/}}: In this folder are {{ic|.desktop}} files. These files determine which programs are loaded for which desktop environment. For an explanation of the desktop file standard refer to [http://standards.freedesktop.org/desktop-entry-spec/latest/ Desktop Entry Specification].
  
 
=== GNOME, KDE, Xfce ===
 
=== GNOME, KDE, Xfce ===
Line 57: Line 58:
 
=== LXDE ===
 
=== LXDE ===
  
 +
If your LXDE is installed according to ArchWiki's guide, Openbox is the default window manager for LXDE. The autostart files specified in the {{ic|Openbox}} will be executed therefore.
 +
* {{ic|/etc/xdg/lxsession/LXDE/autostart}}: global autostart file
 +
* {{ic|~/.config/autostart}}: {{ic|*.desktop}} files or make a symlink to *.desktop files in {{ic|/usr/share/applications/}}
 +
* {{ic|~/.config/lxsession/LXDE/autostart}}: not a shell script. Every line is a program to execute.
 
See [[LXDE#Autostart_Programs]].
 
See [[LXDE#Autostart_Programs]].
  
Line 65: Line 70:
 
=== Openbox ===
 
=== Openbox ===
  
 +
* {{ic|/etc/xdg/openbox/autostart}}: system-wide
 +
* {{ic|~/.config/openbox/autostart}}: user-specific
 
See [[Openbox#Startup programs]].
 
See [[Openbox#Startup programs]].
 +
 +
== Network ==
 +
 +
== Hibernation & Resume ==

Revision as of 20:00, 9 July 2013

This article links to various methods to launch scripts or applications automatically when some particular event is taking place, like system startup or shutdown, shell login or logout and so on.

Daemons

You can easily start your scripts or applications as daemons, see Daemon.

Systemd

systemd is the default init framework, replacing initscripts. The services which are started by systemd can be found in the subfolders of /etc/systemd/system/. Services can be enabled using the systemctl command. For more information about systemd and how to write autostart scripts for it, see at systemd.

Runit

runit is a mature init system which offers process supervision, parallel startup, per-user service trees, granular cgroup manipulation, flexible dependency system, and boot times that don't incur the penalty of dbus. The root-level services are symlinks in /service with the actual service directories in /etc/sv. See the Runit page for more information.

Shell: BASH

To autostart programs in console or upon longin, you can use shell startup files/directories. Read the documentation for your shell, or its ArchWiki article, e.g. Bash or Zsh. Complete startup sequence for bash is explained in the "INVOCATION" section of "man 1 bash". When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc

/etc/profile

/etc/profile is sourced by all Bourne-compatible shells upon login: it sets up an environment upon login and application-specific (/etc/profile.d/*.sh) settings.

Each time /etc/profile is executed, it sources /etc/profile.d/*.sh and /etc/bash.bashrc if they are readable. After reading /etc/profile, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

/etc/bash.bashrc

If not running interactively, it just returns. Or /usr/share/bash-completion/bash_completion is sourced.

~/.bash_profile

~/.bashrc is sourced

Other Shells

Graphical

You can autostart programs automatically when you login into your Window Manager or Desktop Environment.

X session startup

See ~/.xinitrc and ~/.xprofile and /etc/xprofile.

X Desktop Group

  • /etc/xdg/autostart: The folder contains *.desktop files, which will be executed everytime an X session starts.
  • $XDG_CONFIG_HOME/autostart/: In this folder are .desktop files. These files determine which programs are loaded for which desktop environment. For an explanation of the desktop file standard refer to Desktop Entry Specification.

GNOME, KDE, Xfce

GNOME, KDE and Xfce all have a dedicated GUI for autostart settings, see the respective articles.

You can also directly put .desktop files in ~/.config/autostart/

KDE (Legacy)

KDE also has a specific folder: ~/.kde/Autostart or ~/.kde4/Autostart

LXDE

If your LXDE is installed according to ArchWiki's guide, Openbox is the default window manager for LXDE. The autostart files specified in the Openbox will be executed therefore.

  • /etc/xdg/lxsession/LXDE/autostart: global autostart file
  • ~/.config/autostart: *.desktop files or make a symlink to *.desktop files in /usr/share/applications/
  • ~/.config/lxsession/LXDE/autostart: not a shell script. Every line is a program to execute.

See LXDE#Autostart_Programs.

Fluxbox

See Fluxbox#Autostarting Applications.

Openbox

  • /etc/xdg/openbox/autostart: system-wide
  • ~/.config/openbox/autostart: user-specific

See Openbox#Startup programs.

Network

Hibernation & Resume