Sometimes, after I’m done solving some of the big problems I have to work through, I’ll take a time out and go to http://android-casino.org.uk to play some fun games.
You want to run some programs, or export some environment variables, each time X starts – preferably after starting the window manager. This is not always easy.
A method which works with icewm
If you use icewm, you can put the startup commands in an executable file called startup in the directory ~/.icewm (you make it executable by means of the command chmod +x startup).
Example: ~/.icewm/startup for uim:
Programs to be executed should have an & after the program name.
Setting the environment variables (export XMODIFIERS=@im=uim; export GTK_IM_MODULE=uim) does not work from ~/.icewm/startup. You have to set them in some other way, for instance in /etc/environment, or by using the method described below.
A more general method
The following method is due to Osamu Aoki. It works OK with xfce, and maybe with other desktop environments. The commands are, unfortunately, run before the window manager starts. This makes this method somewhat unsuitable if you have icewm.
As root, create a file /etc/X11/Xsession.d/40xfree86-common_user-xsession with the following contents:
if [ -d $HOME/.xsession.d ]; then
if [ -n "$UXFILES" ]; then
for UX in $UXFILES; do
As user, create a directory called .xsession.d in your home directory.
Put any commands you want to run when X starts (including commands for setting environment variables) in a file. Put this file inside ~/.xsession.d . Commands in any files (they do not need to be executable files) inside .xsession.d will be run on each X startup, provided the filename consists of aphanumeric characters, underscores, and hyphens only. So in particular backup files (filename ending in ~), and files with a dot in the filename will not be run.
Example: you want to run scim, which needs the following commands to be run when X starts:
You can put these commands in a file called ~/.xsession.d/scim. The commands will be run when X starts. If you don’t want these commands to be run anymore, you can re-name the file to e.g. ~/.xsession.d/scim.old. Because the filename now has a dot in it, its commands will not be run.
Another example: to run skype (the Internet telephony program) each time X starts, you put a file (called, e.g., skype) inside ~/.xsession.d, just containing the command skype&.