LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Tags used in this thread
Popular LQ Tags , , ,

Reply
 
Thread Tools
Old 01-12-2009, 08:12 PM   #1
fhsm
Member
 
Registered: Jan 2009
Posts: 37
Thanked: 2
How do I remap Alt to a Super Key?


[Log in to get rid of this advertisement]
I've got a laptop that doesn't include a super / windows key. I find this very frustrating. When I had windows on this computer I had mapped one of my alt keys to act like the windows key. I'd like to accomplish the same thing on linux how can I do this?

I tried to make ~/.Xmodmap with the following:
Code:
keycode 108 = Super_R NoSymbol Super_R NoSymbol Super_R
keycode 134 = Alt_R Meta_R Alt_R Meta_R Alt_R Meta_R
Then I ran
Code:
 xmodmap ~/.Xmodmap
Then I ran xev and pressed the right alt key (108) and got:
Code:
KeyPress event, serial 35, synthetic NO, window 0x2200001,
    root 0x65, subw 0x0, time 1298472, (286,-242), root:(897,395),
    state 0x0, keycode 108 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
This suggested to me that it had worked; however, when testing a keyboard shortcut that required the super key it did not work. Next I tested a shortcut that requires an alt key and it did work.

Clearly I don't know what I'm doing. Can someone please help me?
fhsm is offline  
Tag This Post , , ,
Reply With Quote
Old 01-13-2009, 06:56 PM   #2
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495
Thanked: 2
Just a guess (I am also confused by keyboard layouts) but maybe you need to reset Alt_R as a modifier. Run xmodmap -pm to see your current modifiers. I get:

mod1 Alt_L (0x40), Alt_R (0x71), Meta_L (0x9c)
mod4 Super_L (0x7f), Hyper_L (0x80)

(among other stuff). So maybe something like

remove mod1 = Alt_R
add mod4 = Alt_R

would have the required effect.
maroonbaboon is offline     Reply With Quote
Thanked by:
Old 01-14-2009, 04:06 PM   #3
fhsm
Member
 
Registered: Jan 2009
Posts: 37
Thanked: 2

Original Poster
Code:
keycode 108 = Super_R 
remove mod1 = Super_R
add mod4 = Super_R
did the trick, thanks!

One problem: this doesn't survive a reboot. The key mapping part sticks and the remove but not the add. Here's what I get after reboot:
Code:
$ xmodmap -pk | grep 108
   108    	0xffec (Super_R)
$ xmodmap -pm
   mod1         Alt_L (0x40),  Super_R (0x6c),  Meta_L (0xcd)
   mod4         Super_L (0xce),  Hyper_L (0xcf),  Super_R (0x6c)
I can fix this from a restart with either
Code:
 xmodmap ~/.Xmodmap
or
Code:
 xmodmap -e 'remove mod1 = Super_R'
I've tried sudo-ing the ~/.Xmodmap bit but still it doesn't stick. Any suggestions? I find it odd that part of my custom file would get applied but not all...
fhsm is offline     Reply With Quote
Old 01-14-2009, 06:12 PM   #4
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495
Thanked: 2
I've also had the experience of trying to set X resources and having them mysteriously clobbered. I never figured out in any detail what was happening. But as far as I can see on my Debian system the desktop config file ~/.gnomerc gets the last bite on startup so I would give that (or your equivalent) a go for running xmodmap.
maroonbaboon is offline     Reply With Quote
Old 01-15-2009, 06:40 AM   #5
fhsm
Member
 
Registered: Jan 2009
Posts: 37
Thanked: 2

Original Poster
@ marronbaboon Thanks for that suggestion.

Just out of curiosity I tried changing .Xmodmap to:
Code:
keycode 108 = Super_R 
remove mod1 = Super_R
add mod4 = Super_R
remove mod1 = Alt_R
This results in an error on
Code:
 xmodmap ~/.Xmodmap
but gets me correct behavior on startup.

Many hours later this is a total black box.
fhsm is offline     Reply With Quote
Thanked by:

Reply

Bookmarks


Thread Tools

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ALT+B, ALT+F key combinations in xterm don't work nIMBVS cAos 3 04-26-2009 03:16 PM
How do I get Right-Alt key to be just Alt and not generate special characters? (KDE) KWTm Linux - General 2 06-25-2005 10:26 PM
Key remap Silverdaz Linux - Software 1 07-08-2004 12:35 PM
remap keyboard windows key khtse Slackware 2 07-01-2004 02:14 PM
Key remap Silverdaz Fedora 0 06-23-2004 09:28 AM


All times are GMT -5. The time now is 06:18 AM.

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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration