Saturday, October 20, 2012

numlock on kde under gentoo linux

I find it very annoying that linux seems to have no uniform way to just turn the numlock on when the system comes on and leave it that way. Every minor change of environment resets the numlock back to off, which I can't really imagine anyone actually wanting. Well, maybe people without numeric keypads where the numlock steals part of their keyboard, but for the majority of people who have a standard ANSI 104 key keyboard, I would think you'd want the numlock on by default. Windows understands this, so why doesn't linux?

I use KDE, and there is a setting in KDE that lets you turn the numlock on when you login. However, it doesn't work for all situations. For some reason, the console is a separate environment from the X server (running KDM) which is a separate environment from KDE, and each one has an individual numlock state.

The console is a minor annoyance for me, since I rarely use it, but it's the easiest one to fix so we'll start here. To turn numlock on for your console, simply add the numlock init.d script to your default rc script. e.g. "rc-update add numlock default". When you reboot, numlock will be on by default for the console.

The second enviroment, KDM (the KDE Display Manager) requires a change to the kdmrc file. For some reason, gentoo puts this file in /usr/share/config/kdm rather than somewhere in /etc like I would expect. I know they put it somewhere else on Kubuntu, so if you don't use gentoo, you'll have to find the kdmrc file yourself. Edit this file and look for the line NumLock=Off and change it to NumLock=On and uncomment the line. The next time KDM is started, numlock will be enabled.

The third environment, KDE, requires a change in the Keyboard settings. Go to Settings, Hardware, Input Devices, Keyboard and change Numlock on KDE Startup to to Turn on.

There was a fourth hidden environment for me, which occurs because I use gentoo keychain run from .bash_profile using the x11-ssh-askpass (just ssh-askpass on Ubuntu, btw). So my .bash_profile has some lines like this in it:

export SSH_ASKPASS="/usr/bin/x11-ssh-askpass"
keychain ~/.ssh/id_rsa

So after logging in with KDM (where the numlock was on), numlock would go back to being off before KDE would put it back on with the settings, so x11-ssh-askpass would require me to turn numlock on AGAIN. We can counter this by using numlockx. You can install it using "emerge numlockx" as root. Then we can change the .bash_profile to use numlockx before running keychain.

export SSH_ASKPASS="/usr/bin/x11-ssh-askpass"

if [ x$DISPLAY != x ]; then
        numlockx
fi

keychain ~/.ssh/id_rsa

Finally, I never have to turn on numlock when I'm logging in.

2 comments:

  1. It was awesome article to read. Complete rich content and fully informative. The article you have shared here is very informative and the points you have mentioned are very helpful. Thank you so much. Xfinity Tv Package Deals In Florida.

    ReplyDelete
  2. Slots with Bonuses | Casino Site & Games
    The selection of slots with bonus features, jackpots, and other bet365 rewards is amazing. slot 1xbet games, 카지노 also known as video slots, are popular in Canada.

    ReplyDelete