Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Do you run xmodmap or other commands everytime you start an X session, or everytime you login via KDM/GDM/etc? There are two lovely options available! The first is your best bet and solves most situations.

After X Starts

The ~/.xprofile file is executed after X starts, regardless of the way it is started: xstart, xinit, KDM, XDM, GDM, et cetera. All you have to do is fill up the file like the example below:

File: ~/.xprofile
#Put the commands you want to run at startup in here.
xmodmap -e "5 4 3 2 1 9 10 6 7 8" 
xmodmap .xmodmap
gaim &
thunderbird &

The ampersand (&) makes the process go to the background and therefore not make your script wait before continuing.

Before X starts

If you're not sure what you are doing, ignore this.

If you are starting X via xstart or xinit, you can modify the ~/.xinitrc file to contain commands to be executed before X finishes starting. This file is not executed for users of most login managers: KDM, XDM, GDM, etc.

File: ~/.xinitrc
#Put the commands you want to run at startup in here.
exec openbox

Warning: Remember, this file should also contain the execution command for your window manager, i.e. openbox as seen above.
Retrieved from ""

Last modified: Sat, 06 Sep 2008 07:26:00 +0000 Hits: 11,229