Saturday, March 15, 2008

Running Applications Automatically when X Starts

I've been looking for a way to start applications automatically, when X starts. In GNOME it's just a matter of adding an entry to the list of programs that are launched when a session starts.

Other session/window managers use other methods, or do not provide a startup facility at all. In the latter case, you usually have to roll your own X startup script. But with GDM on Debian you just have to add your custom shell commands in ~/.xprofile. At the moment I use it to set the root window background color, and launch x11vnc, for non-GNOME sessions:
# start a few programs for non-gnome window managers
# the conditional is based on /etc/X11/Xsession.d/55gnome-session_gnomerc
BASESTARTUP=`basename "$1" | cut -d\ -f1`
if [ ! \
\( "$BASESTARTUP" = gnome-session -o \
\( "$BASESTARTUP" = x-session-manager -a \
"`readlink /etc/alternatives/x-session-manager`" = \
/usr/bin/gnome-session \) \) ]; then
# plug your stuff here
xsetroot -solid black
x11vnc --forever -localhost -display :0 -rfbauth .vnc/passwd &
(don't forget to make it executable with chmod +x ~/.xprofile )

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.