Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP: move Capslock on console to Shift-ShiftLock key
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
javeree
Apprentice
Apprentice


Joined: 29 Jan 2006
Posts: 298

PostPosted: Thu Jan 29, 2009 10:37 am    Post subject: TIP: move Capslock on console to Shift-ShiftLock key Reply with quote

I never use CapsLock ! Never ? Yes I very often 'use' it when I accidentally press the ShiftLock key and write things like EMERGE __SYNC _UdnATV WORLD.

So I was looking for a way to disable the ShiftLock key while working on console. In addition, just in case someone might actually want to use CapsLock, I wanted to make it possible to use Shift - ShiftLock to activate and deactivate CapsLock.
Note: in the above, I use ShiftLock to mean the key, and CapsLock to mean the functionality.

It turned out I had to take some time and attentively read man loadkeys and man keymaps. I will not reiterate the contents here, but just explain my conclusions

First make sure you know the keycode from the ShiftLock key by running (from a console, not a terminal emulator under X):
Quote:
showkey
and press the ShiftLock key. you'll see something like
Quote:
keycode 58 press
keycode 58 release

Wait for 10 seconds to return to the prompt.

using loadkeys, we can now easily change the key assignment
this can be done manually (as root) from the command line)
Quote:
loadkeys >> EOF
plain keycode 58 = VoidSymbol
shift keycode 58 = Caps_Lock
EOF


However, a cleaner way is to create a keymap that can be loaded by /etc/init.d/keymaps

Quote:
cd /usr/share/keymaps/i386/include # where the keymaps for my pc are stored

# create the keymap file
cat << EOF >> shiftcaps.map
keycode 58 = VoidSymbol
shift keycode 58 = Caps_Lock
EOF

gzip shiftcaps.map # compress it into shiftcaps.map.gz


Now edit the key EXTENDED_KEYMAPS in /etc/conf.d/keymaps

I have

Quote:
EXTENDED_KEYMAPS="backspace keypad euro2 shiftcaps"


The last word ('shiftcaps', not 'shiftcaps.map.gz') makes loadkeys load the new keymap when you run

Quote:
/etc/init.d/keymaps restart


Last edited by javeree on Thu Jan 29, 2009 12:58 pm; edited 2 times in total
Back to top
View user's profile Send private message
jfp
Apprentice
Apprentice


Joined: 08 Jul 2007
Posts: 277
Location: Virginia, USA

PostPosted: Thu Jan 29, 2009 11:54 am    Post subject: Reply with quote

javeree,
Thank you very much. This could be the next great advance in computing.

I am having trouble finding the showkeys command. Do you know what package contains it?
Code:
equery belongs showkeys

_________________
jfp
Back to top
View user's profile Send private message
jfp
Apprentice
Apprentice


Joined: 08 Jul 2007
Posts: 277
Location: Virginia, USA

PostPosted: Thu Jan 29, 2009 12:27 pm    Post subject: Reply with quote

Found it... It is not "showkeys", but "showkey".
Code:

zippy logrotate.d # equery belongs showkey
[ Searching for file(s) showkey in *... ]
sys-apps/kbd-1.13-r1 (/usr/bin/showkey)

_________________
jfp
Back to top
View user's profile Send private message
javeree
Apprentice
Apprentice


Joined: 29 Jan 2006
Posts: 298

PostPosted: Thu Jan 29, 2009 12:58 pm    Post subject: Reply with quote

corrected in the original post
Back to top
View user's profile Send private message
sleipner
n00b
n00b


Joined: 13 Aug 2005
Posts: 48

PostPosted: Fri Jan 30, 2009 7:14 am    Post subject: Reply with quote

great tip javeree!


i changed capslock to esc like i do under x.. it makes using vim so much nicer :)

Code:

keycode   58 = Escape         
   alt   keycode   58 = Meta_Escape     
   shift   alt   keycode   58 = Meta_Escape     
   altgr   alt   keycode   58 = Meta_Escape     
   control   alt   keycode   58 = Meta_Escape     
   shift   control   alt   keycode   58 = Meta_Escape     
   altgr   control   alt   keycode   58 = Meta_Escape
Back to top
View user's profile Send private message
GetCool
Guru
Guru


Joined: 23 Nov 2003
Posts: 324
Location: Madison, Wisconsin

PostPosted: Tue Feb 17, 2009 7:16 am    Post subject: Re: TIP: move Capslock on console to Shift-ShiftLock key Reply with quote

Wow, thanks... I've always edited /usr/share/keymaps/i386/qwerty/us.map.gz directly to make my customizations, and for some reason I never even noticed the EXTENDED_KEYMAPS variable before... and I've been editing the keymaps file for years! Am I blind?

Now I can put all kinds of crazy custom extensions in there without editing the default keymap file. Fantastic.
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2147

PostPosted: Wed Feb 18, 2009 7:50 am    Post subject: Reply with quote

Thanks for this, working good, but one question @sleipner:

When I include
Code:
shift   control   alt   keycode   58 = Meta_Escape     
altgr   control   alt   keycode   58 = Meta_Escape


I get an error stating
Code:
loadkeys: /usr/share/keymaps/i386/include/ph_esc-lock.map.gz:7: adding map 13 violates explicit keymaps line
* ERROR: keymaps failed to start


Any hint on that? My default keymap is
Code:
keymap="de-latin1-nodeadkeys"


Edit, under X, is there a better way as using xmodmap?
Back to top
View user's profile Send private message
sleipner
n00b
n00b


Joined: 13 Aug 2005
Posts: 48

PostPosted: Wed Feb 18, 2009 8:59 am    Post subject: Reply with quote

my keymap is fi-latin9 so that might do the difference.

this should give you correct keymap for escape, just copy needed lines to your keymap file and replace keycodes
Code:

dumpkeys|grep Escape
Back to top
View user's profile Send private message
avx
Advocate
Advocate


Joined: 21 Jun 2004
Posts: 2147

PostPosted: Wed Feb 18, 2009 9:32 am    Post subject: Reply with quote

Thanks, for the reference, this is my output
dumpkeys | grep -i escape wrote:
keycode 1 = Escape Escape
alt keycode 1 = Meta_Escape
shift alt keycode 1 = Meta_Escape
keycode 4 = three section threesuperior Escape
control alt keycode 4 = Meta_Escape
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum