LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-04-2007, 08:47 PM   #1
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Rep: Reputation: 15
Extra keyboard buttons on console (not X11)


Hello guys! Well, I would like to make a use for my extra keyboard keys (windows logo left, windows logo right, mute, stop, play, etc.). I know it can be done on X, but I would like to know how can it be done on console? If I already know the keycode, what file can I edit to assign it supposing I'm using bash? I began to think about it after seeing PC Linux OS Distribution assigning the windows logo to switch terminals (tty1, tty2, tty3...) so I'm curious to know how can it be made in another dists.

Again, I'm speaking about console not X11!

Thanks in advance!
 
Old 07-05-2007, 08:16 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
Hi

Heres' how I assigned next and previous consoles on the text console to Windows key left and right:

In /etc/rc.local (so it is executed each time my linux box starts up):

sh -f /root/setupkbd.sh

and in /root/setupkbd.sh I have:

setkeycodes e05f 89
setkeycodes e021 90
setkeycodes e06b 91
setkeycodes e032 92
setkeycodes e065 93
setkeycodes e066 94
setkeycodes e06C 95
loadkeys /root/mykeys

which assigns my F1 - F6 and F11 and F12 to IDs 89-95. I got the scancodes by running showkey in a console mode.

Then, in /root/mykeys I have

keycode 125 = Decr_Console
keycode 126 = Incr_Console
altgr keycode 59 = Console_1
altgr keycode 60 = Console_2
altgr keycode 61 = Console_3
altgr keycode 62 = Console_4
altgr keycode 63 = Console_5
altgr keycode 64 = Console_6
altgr keycode 65 = Console_7
altgr keycode 66 = Console_8
altgr keycode 67 = Console_9
altgr keycode 68 = Console_10
keycode 59 = F110
string F110 = "root"
keycode 60 = F111
string F111 = "rylan"
keycode 88 = F100
string F100 = "shutdown -h now"
keycode 61 = F101
string F101 = "su"
keycode 62 = F102
string F102 = "startx"
keycode 63 = F103
string F103 = "df -mh"
keycode 64 = F104
string F104 = "find / -name "
keycode 65 = F105
string F105 = "exit"
keycode 87 = F106
string F106 = "reboot"

Hope this helps!

Regards,

Last edited by rylan76; 07-05-2007 at 08:18 AM.
 
Old 07-05-2007, 09:50 AM   #3
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Original Poster
Rep: Reputation: 15
Hello Stefan! I thank you so much for your help, but unfortunately it didn't work. I've got the following codes for the following keys using the 'showkey' command:

LWindowsLogo = 0x7d
RWindowsLogo = 0x7e
MouseRightButton = 0x7f


'showkey' also prints the message "kb mode was XLATE", dunno if it is relevant but...

So I've added the following entry to my /etc/profile:

setkeycodes 0x7d 141
setkeycodes 0x7e 142
setkeycodes 0x7f 143
loadkeys /etc/mykeys


And in /etc/mykeys:

keycode 141 = Decr_Console
keycode 142 = Incr_Console
keycode 143 = F100
string F100 = "find / -name "


It prints the alert "Loading /etc/mykeys" on login, and doesn't print any error, but the keys simply don't work...? At first I thought there could have something to do with my system not understanding "Decr_Console" and "Incr_Console", but not even "find / -name " worked. Do you have any ideas about what could be wrong? I've already tried to set different codes like 91, 92...201, 202...but no results! :/

Thanks again!

Last edited by icmp_request; 07-05-2007 at 09:52 AM.
 
Old 07-06-2007, 12:39 AM   #4
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Original Poster
Rep: Reputation: 15
Ok seems I solved it, *finally*! After so much research I've made it was quite simple! :P

First, I created a /etc/init.d/keyb2 script:

# Begin /etc/init.d/keyb2

loadkeys /etc/mykeys

# End /etc/init.d/keyb2


Now, for /etc/mykeys:

keycode 0x7d = Decr_Console
keycode 0x7e = Incr_Console
keycode 0x7f = F100
string F100 = "find / -name "


These keycode values I received using the showkey command. Instead of appending a setkeycodes value for them, I just used the raw values themselves I received and bingo! As far as I could understand, showkey already displays the keycode value of a pressed key by default. So it's just use this value!

I don't need to mention that I created symlinks in /etc/rcX.d/S80keyb2 to /etc/init.d/keyb2 where X are the runlevels from 2 to 5.

*Thread Solved!*
 
Old 07-06-2007, 12:40 AM   #5
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,475

Rep: Reputation: 87
Quote:
Originally Posted by icmp_request
Hello Stefan! I thank you so much for your help, but unfortunately it didn't work. I've got the following codes for the following keys using the 'showkey' command:

LWindowsLogo = 0x7d
RWindowsLogo = 0x7e
MouseRightButton = 0x7f


'showkey' also prints the message "kb mode was XLATE", dunno if it is relevant but...
Whoa! No, I've got no idea why you get hex - I think those are scancodes. If you convert the hex to decimal, and use that in the setting up o fthe keys, does it work? I. e. key 0x7d in he = 125 in decimal? I. e. use 125 as the code?
 
Old 07-06-2007, 12:46 AM   #6
icmp_request
Member
 
Registered: Jun 2007
Location: 127.0.0.1
Distribution: Changing a lot over time
Posts: 46

Original Poster
Rep: Reputation: 15
Wow! 1min later you came with the solution...funny hahahahah!
 
  


Reply

Tags
keycodes


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I use the extra buttons on my keyboard? (SuSE, KDE) Nebetsu Linux - General 4 12-18-2006 04:06 AM
Extra Mouse Buttons Stabby McTwist Linux - Hardware 5 11-06-2006 12:11 AM
Using extra keyboard buttons? Anjin Mandriva 2 05-24-2004 04:11 AM
Extra buttons on i8200 fettouhi Linux - Newbie 0 10-18-2003 01:59 AM


All times are GMT -5. The time now is 01:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration