banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Tip Top Tips: Xfce Configuration For The CAPS-LOCK


by Davecs
from The PCLinuxOS Forum


Do you ever look up from your keyboard to the screen, only to see that you've typed everything in CAPS, and you have to delete and retype it? You'd pressed the CAPS key in error. It happens.

Now in the Xfce Settings Manager > Keyboard > Layout, it's possible to reassign CAPS LOCK to Compose, meaning that the worst that can happen if you accidentally hit the CAPS key is that one character has to be replaced by 2 or 3. However, if you do that, there may be times when you actually require CAPS to be LOCKed. One example here in Britain is when you get a loyalty voucher from a well-known supermarket chain, and to claim it, you have to enter a long string of characters consisting of numbers and capital letters, and you don't want to keep alternating the SHIFT key as you type. Lower case letters result in an error. It is possible to set CAPS LOCK by pressing both SHIFT keys via the KDE Control Centre, but not Xfce.

As a sort of extra, there is a redundant light on most keyboards, the SCROLL LOCK indicator. If you have more than one language/layout setting on your keyboard, the Xfce Settings Manager>Keyboard>Layout, enables you to use a key (e.g. Scroll Lock) to switch between layouts, but does not allow you to toggle the indicator on the keyboard. This feature is enabled in the KDE Control Centre, but not in Xfce.

Well, here is a short script which will enable you to set CAPS LOCK by pressing both SHIFT keys together, and turning it off by pressing a single SHIFT key. It will also enable the SCROLL LOCK lamp to come on when you switch to your secondary keyboard layout. I've called it "keyboard-extras" and put it in the folder /usr/local/bin/. It has to be saved as root and made executable.

#!/bin/bash

#wait a while to let original setup finish first,
#on a slow computer you might need to give it more time
#otherwise the changes made in this script will be overwritten
#and ineffective

sleep 10

#this line adds the option for two shift keys together to set
#CAPS LOCK, and one of them alone to cancel it.

setxkbmap -option "shift:both_capslock_cancel"

#this line causes the SCROLL LOCK lamp to come on when you
#switch to your secondary keyboard layout.

setxkbmap -option "grp_led:scroll"

#other lines as necessary

Now all you have to do is add a new item to Xfce Settings Manager > Session and Startup as follows:

Name: Keyboard Extras
Description: Add extra features to keyboard
Command: /usr/local/bin/keyboard-extras
Trigger: on login

And you will have these extra features when you next log in!



Previous Page              Top              Next Page