Running applications automatically when X starts
Posted by Steve on Thu 2 Dec 2004 at 19:45
The majority of people who use Debian upon the desktop launch straight into the X11 Window system, usually via one of the choosers xdm, gdm, or kdm. Once you've entered your username and password you get your Window Manager running and are ready to start work. But what if you want a program or two to start as soon as you login?
The bigger desktop environments such as KDE or GNOME have their own facilities for starting programs when they load up.
In the case of KDE you simply place a shellscript, or symbolic link to an executable, into a special startup directory:
/home/username/.kde/Autostart
This will be executed at login time.
For GNOME you can use the control center. Go to the Control Center and select the sessions option. Inside there use the Session Properties & Startup section to choose the 'Startup Programs' tab. This allows you to add new programs to run at startup.
But what about causing programs to run if you're not running those environments?
Well the choosers gdm, kdm and xdm all support a standard startup system.
These choosers use XSession to run programs either globally or per-user when you login.
The global options are suitable if you wish to run a program for any user who logs into your machine, the per-user settings only apply to yourself.
Global options are the simplest ones. Simple place a shell script (make it executable) into the directory /etc/X11/Xsession.d
The files in the Xsession.d are executed in the order they are found - which explains why you might find some scripts located there already with numbers in their names.
I almost always want to have a terminal open and the music player xmms running when I login. I can achieve this by saving following shell script as /etc/X11/Xsession.d/startup-local
#!/bin/sh xmms & xterm &
Make it executable with:
chmod 755 /etc/X11/Xsession.d/startup
Notice that you must put the commands to run in the background? If you don't do that then your window manager will not start until after those programs have exitted.
If you just want to do this for yourself you can achieve the same thing by saving the script to run as ~/.xsession:
#!/bin/sh xmms & xterm &
(Again making it executable).
This is the per-user configuration file and will only affect you.
Either of these systems allow you to start programs automatically with the leighter weight Window Managers such as my personal favorite IceWM.
I know this is off topic but I really just want to say thank you for the articles. I have only been running my own server for a few months, which is when I started using Debian. And there are just lots of little things that this site has helped to point out. Nathan Bullock
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
i do the following: vim ~/.xsession
and in the file i write:
#!/bin/sh
gaim &
(i want gaim initiate when i enter in X)
But then when i login it gives me an error that my last session has dured less than 10 secods and it get outs the session
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Any diffrent methods of running? Someone could help me?
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
- gdm calls /etc/gdm/Xsession
- XSession sources a whole buch of scripts in /etc/X11/Xsession.d
- one of them is called 50xfree86-common_determine-startup
So what does this script do?
It checks if an argument was passed to the Xsession script (by gdm), and only if NO argument was passed to the Xsession script (and the appropriate Option is set in /etc/X11/Xsession.options), it will execute the user defined session script (~/.xsession).
[ Parent | Reply to this comment ]
hope this helps.
[ Parent | Reply to this comment ]
nano /etc/X11/Xsession.d/xbindkeys
I put there:
#!/bin/sh
xbindkeys &
And I make:
sudo chmod 755 /etc/X11/Xsession.d/xbindkeys
Just in case, I do:
/etc/init.d/gdm stop
/etc/init.d/gdm start
But when I log-in to Enlightenment xbindkeys is not loaded.
Does anybody have an idea what is the reason?
10x
[ Parent | Reply to this comment ]
E.g. vmware needs to run it's toolbox as root to be somehow useful. Now I want to load the toolbox automatically when the user's XFCE4's desktop is started. How to do that? Problem is that this should run without user interference...
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]