Why KDM?

KDM, the default display manager for KDE, starts when your X server instance begins. This means that the user has still not logged in, and any settings established at this point will apply to all users. Moreover, making these changes in KDM is often safer and easier than modifying your xorg.conf file or coming up with some hack that will only work for a particular user once he or she has logged in.

How to Run Scripts

KDM has its own startup script called Xsetup. When X is started, KDM will execute anything within this script file. To run your own scripts, all you have to do is tell Xsetup to execute them. For example, you might want to run xrandr when KDM starts. This will automatically configure your monitor or multiple monitors to your preferred settings, and those settings will stick when any user logs into KDE, unless they override them. To accomplish this, follow these steps: In most cases, it is a good idea to place your command string before this line: That will execute your script before KDM starts.

Another example of something you might want to execute before KDM starts is to set Numlock to either “on” or “off”. KDE has a setting for this, but setting it in KDM will essentially enable a global default. To enable or disable numlock, follow these steps: Just to reiterate an important point, you should always be mindful that anything you put in Xsetup will be executed by root and will affect anyone who logs in with KDM, no matter the user or desktop environment they choose from the KDM menu. This can have far-reaching consequences, particularly if you have a multi-user system. Safety issues aside, using KDM’s Xsetup script is a great way to get your desktop exactly the way you want it even before you login. Whether you are enabling numlock or even setting up a custom keymap with Xmodmap, you can do it from Xsetup and not have to worry about configuring it after you start your user session.