You are not logged in.

#1 2013-06-29 00:14:45

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

[SOLVED]Remap my menu key in Xorg

Hi, everyone!

I have a menu key of no use on my keyboard, and I want to use it. So I decide to remap it. I want to do this mapping:

menu + 1 => F1
menu + 2 => F2
menu + 3 => F3
menu + 4 => F4
menu + 5 => F5
menu + 6 => F6
menu + 7 => F7
menu + 8 => F8
menu + 9 => F9
menu + 0 => F10
menu + - => F11
menu + + => F12
menu + w => ArrowUp
menu + d => ArrowDown
menu + a => ArrowLeft
menu + d => ArrowRight
menu + j => PageDown
menu + k => PageUp
menu + m => End
menu + , => Home

This means if I press menu key and 1 at once, it equals to F1. It seems that Xmodmap can't be suitable because it can't map combination keys. Do you have any idea of the way to do it?

Thank you.

Last edited by Maxfan Zone (2013-06-30 00:33:49)

Offline

#2 2013-06-29 01:22:12

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]Remap my menu key in Xorg

What key is this "menu" key you speak of?  Are you talking about mod4?  Or is there some magic "menu" key on your keyboard that is not common?

I think this functionality would be highly dependent on what you are using as a graphcal environemnt.  Though there are some programs that can help with this functionality that are stand alone as well.  One of them is xbindkeys.

Offline

#3 2013-06-29 01:48:41

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

I'm sorry I didn't make it clear. On PC keyboards, the menu key is on the left of right control, under right shift.
This graphical environment I'm using is simply Xorg with a window manager, not Gnome or KDE.
I'm studying xbindkeys, thanks for your reply.

Offline

#4 2013-06-29 01:54:02

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED]Remap my menu key in Xorg

You can use "xev" to get the keycode that is sent when you press the menu key.

Offline

#5 2013-06-29 01:56:06

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]Remap my menu key in Xorg

Even with a stand alone window manager, sometimes there is the inclusion of this functionality.  For example, openbox is able to handle thse in the rc.xml, and i3 does it in ~/.config/i3/config (unless you specify a different config file when starting it).

On second thought... I'm not sure if you can actually map a key combination to another key combination.  Typically you specify a command to run on the keypress.

Last edited by WonderWoofy (2013-06-29 01:57:03)

Offline

#6 2013-06-29 02:02:12

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

Xev: keycode 135 (keysym 0xff67, Menu)

The window manager is Awesome.

Offline

#7 2013-06-29 02:08:52

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED]Remap my menu key in Xorg

https://wiki.archlinux.org/index.php/Xb … bindkeysrc

Unfortunately, xbindkeys does not appear to recognize the "menu" key as a modifier. There are other tools (I know there was one posted on the forum recently) and awesome may have some native keymapping mechanism, but I don't use it so I can't help with that.

(edit) here is another keybind tool: https://bbs.archlinux.org/viewtopic.php?id=155613

Last edited by 2ManyDogs (2013-06-29 02:16:53)

Offline

#8 2013-06-29 02:19:07

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]Remap my menu key in Xorg

Okay, so I don't use awesome.  But I wonder if you could use xdotool to simulate a particular keypress (like F1 for example), and then bind that command to something via your window manager's keyboard shortcut function.  I know that awesome has this functionality, but I have just never used awesome personally.  Otherwise you could use xbindkeys to have it work universally across all window managers and desktop environments.

Offline

#9 2013-06-29 02:24:31

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

Thanks, xdotool really can simulate a keypress, but it seems that awesome can't bind 'menu' key, neither can xbindkeys.
EDIT: But can I remap 'menu' key to 'hyper' via xmodmap?

Last edited by Maxfan Zone (2013-06-29 02:25:24)

Offline

#10 2013-06-29 02:27:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,500
Website

Re: [SOLVED]Remap my menu key in Xorg

The trick is binding a *combination* of keys.

As the menu key is not a modifier, presing Menu+j for example will yeild events menu-pressed, j-pressed, j-released, menu-released.  None of those events will "know" about the others in most keybinding functions.  Contrast this with Mod4+j which yeilds mod4-pressed, j-pressed-while-mod4-held, j-released-while-mod4-held, mod4-released.  This is what is unique to modifier keys: their state is sent with every keypress.

In order to bind menu+j (or menu+f1, etc) you need to either turn 'menu' into a modifier (not sure if that's possible [edit: it seems it is, see two posts down - this is your best option]), or use a key chaining function which can read sequences of keys and bind them to actions.

At the simplest (but also probably worst) implementation, you could use typical methods to bind 'menu' to launch a custom script.  That script will read one key press, then have a case statement to do different actions based on what that key was.

For a better implementation of this you'll want to look for tools that key chains for bindings - which I thought awesome does by default, but I used awesome for about a day, if that.

EDIT: they can *definitely* bind the menu key.  You just need to get the syntax right.  See above for what they can't bind.

Last edited by Trilby (2013-06-29 02:31:21)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#11 2013-06-29 02:27:48

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]Remap my menu key in Xorg

Really... hmmm.  That seems silly.  No, it can, I just checked.  I guess what you would need to do is add the menu key to a modifier key.  By default, I think that mod3 is empty.  So you would add that keycode or keysym to mod3, then map mod3+<whatever> to the xdotool command.

Of course, I don't have a "menu" key, so take that with a grain of salt.  I tried with a different key... namely, my PrtSc key, which is in the same spot.

Last edited by WonderWoofy (2013-06-29 02:28:39)

Offline

#12 2013-06-29 02:30:10

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED]Remap my menu key in Xorg

Maxfan Zone wrote:

Thanks, xdotool really can simulate a keypress, but it seems that awesome can't bind 'menu' key, neither can xbindkeys.
EDIT: But can I remap 'menu' key to 'hyper' via xmodmap?

What's "hyper"?

You might be on to something there, though -- this xmodmap remaps the menu key to mod4:

keycode 135 = Super_L NoSymbol Super_L

Once I did that I could use the menu key like a mod4 key. I have mod4+t mapped to start a terminal, and now I can use menu+t to do the same thing.

Last edited by 2ManyDogs (2013-06-29 02:32:28)

Offline

#13 2013-06-29 02:32:44

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

I read here: https://wiki.archlinux.org/index.php/Ex … ys_in_Xorg
I have known that keycode of menu key is 135, but what's keysym of Mod3?

EDIT: Don't do that, Mod4 is Awesome's default shortcut key, it is used to manage windows.

Last edited by Maxfan Zone (2013-06-29 02:34:46)

Offline

#14 2013-06-29 02:36:03

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED]Remap my menu key in Xorg

There are two different mappings in the output of xmodmap.  If you use -pke, you can see all they keys as they would output information when pressed.  If you use -pm, you can see the "modifier" designations that certain keys are assigned to.  These include control, shift, mod1-mod5, and (caps)lock.  So your Shift_L key for example will have a keycode, but it will also be listed in the "shift" modifer list as well.  This should all be in the documentation.

Offline

#15 2013-06-29 02:39:57

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED]Remap my menu key in Xorg

Maxfan Zone wrote:

EDIT: Don't do that, Mod4 is Awesome's default shortcut key, it is used to manage windows.

I was just trying to show you that the menu key could be remapped. I'll let you figure out exactly how to do what you want.
Do you not have function keys? I don't really understand what you're trying to do (and why) except as an exercise. I'm done now.

Last edited by 2ManyDogs (2013-06-29 02:40:45)

Offline

#16 2013-06-29 02:49:47

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,500
Website

Re: [SOLVED]Remap my menu key in Xorg

I think it could be worthwhile.  I don't know the OP's intent, but having an additional modifier key could be handy - particularly if there is an used key just hanging out at a convenient spot on the keyboard.

Take any tiler as an example, Mod4+# will (generally) move to that tag/workspace.  But then you want to be able to move a *window* to a tag/workspace - ok, we can use Shift+Mod4+#.  But what if you want to toggle the window's presence on a tag: Ctrl+Mod4+#, or toggle visibility of a tag: Ctrl+Alt+Mod4+3, or ...

This all might be perfectly natural for emacs users, but we mere mortals with only ten fingers can get a bit tied up.  Having bindings for Menu+# could be quite handy (or fingery?).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#17 2013-06-29 02:54:21

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

Thanks for WonderWoofy ,Trilby and 2ManyDogs' generous help.

I have to be offline, here is a summary:

First use xmodmap to bind 'menu' key to Mod3, then edit ~/.xkeybinds :

"xdotool key F1"
    mod3 + 1

"xdotool key F2"
    mod3 + 2

"xdotool key F3"
    mod3 + 3

"xdotool key F4"
    mod3 + 4

"xdotool key F5"
    mod3 + 5

"xdotool key F6"
    mod3 + 6

"xdotool key F7"
    mod3 + 7

"xdotool key F8"
    mod3 + 8

"xdotool key F9"
    mod3 + 9

"xdotool key F10"
    mod3 + 0

"xdotool key F11"
    mod3 + -

"xdotool key F12"
    mod3 + =

Run command 'xbindkeys'. Then press 'menu' and 1 at the same time, I'll see it works like F1. Is this idea right?

Last edited by Maxfan Zone (2013-06-29 14:06:27)

Offline

#18 2013-06-29 02:54:30

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED]Remap my menu key in Xorg

(to Trilby) Yes, in the general case. I might map menu+r to reload my WM config, instead of mod4+shift+r. But his specific case of mapping menu+1 to F1 makes no sense to me, unless he doesn't have function keys (or he has really short fingers that can't reach the function row). In any case, this was an interesting exercise, but I need sleep.

Last edited by 2ManyDogs (2013-06-29 02:56:12)

Offline

#19 2013-06-29 14:08:11

Maxfan Zone
Member
From: Liaoning, Chaoyang, China
Registered: 2013-06-27
Posts: 7
Website

Re: [SOLVED]Remap my menu key in Xorg

Hi, I made some progress, the problem is partly solved.

In ~/.Xmodmap:

xmodmap -e "add mod3 = Menu"

In ~/.config/sxhkd/sxhkdrc:

# don't take action if I press Menu
Menu
    true

mod3 + 1
    xdotool key --clearmodifiers F1

mod3 + 2
    xdotool key --clearmodifiers F2

mod3 + 3
    xdotool key --clearmodifiers F3

mod3 + 4
    xdotool key --clearmodifiers F4

mod3 + 5
    xdotool key --clearmodifiers F5

mod3 + 6
    xdotool key --clearmodifiers F6

mod3 + 7
    xdotool key --clearmodifiers F7

mod3 + 8
    xdotool key --clearmodifiers F8

mod3 + 9
    xdotool key --clearmodifiers F9

mod3 + 0
    xdotool key --clearmodifiers F10

mod3 + minus
    xdotool key --clearmodifiers F11

mod3 + equal
    xdotool key --clearmodifiers F12

mod3 + w
    xdotool key --clearmodifiers Up

mod3 + s
    xdotool key --clearmodifiers Down

mod3 + a
    xdotool key --clearmodifiers Left

mod3 + d
    xdotool key --clearmodifiers Right

mod3 + j
    xdotool key --clearmodifiers Page_Down

mod3 + k
    xdotool key --clearmodifiers Page_Up

mod3 + m
    xdotool key --clearmodifiers End

mod3 + comma
    xdotool key --clearmodifiers Home

And run sxhkd(it's in AUR), see it's working.

Note some part also need fixing.

Greatly thanks for WonderWoofy, Trilby and 2ManyDogs.

EDIT: Now it is completely solved.

Last edited by Maxfan Zone (2013-06-30 00:30:08)

Offline

Board footer

Powered by FluxBB