2

I'm trying to remap my Insert key to End and shift+Insert to Home on Ubuntu 16.10. Inspired by Map Super+[Left|Right] to Home/End and some other resources I made the following mysymbols file:

partial modifier_keys
xkb_symbols "insert_end_home" {
   key <INS>  {[    End, Home     ]};
};

It works for the End, but shift+Insert does not produce the Home function. How can I fix this?

EDIT

After modifying with xmodmap as suggested by @dirkt I still get only Home or only End. Here is the output of xev when I press Insert and then when I press shift+Insert. There is indeed a FocusOut event, but what does it mean?

KeyPress event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56790713, (-342,308), root:(439,360),
    state 0x0, keycode 118 (keysym 0xff50, Home), same_screen YES,
    XKeysymToKeycode returns keycode: 110
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56790753, (-342,308), root:(439,360),
    state 0x0, keycode 118 (keysym 0xff50, Home), same_screen YES,
    XKeysymToKeycode returns keycode: 110
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56796591, (-342,308), root:(439,360),
    state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56796755, (-342,308), root:(439,360),
    state 0x1, keycode 118 (keysym 0xff57, End), same_screen YES,
    XKeysymToKeycode returns keycode: 115
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56796811, (-342,308), root:(439,360),
    state 0x1, keycode 118 (keysym 0xff57, End), same_screen YES,
    XKeysymToKeycode returns keycode: 115
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x3800001,
    root 0xed, subw 0x0, time 56797003, (-342,308), root:(439,360),
    state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

FocusOut event, serial 37, synthetic NO, window 0x3800001,
    mode NotifyNormal, detail NotifyNonlinear

PropertyNotify event, serial 37, synthetic NO, window 0x3800001,
    atom 0x168 (_NET_WM_STATE), time 56802723, state PropertyNewValue

Also, here's the output of xmodmap -pm:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)
2
  • Instead of trying to make your own xkb files, why don't you just use xmodmap and ~/.Xmodmap?
    – dirkt
    Commented Feb 15, 2017 at 17:31
  • Because I searched for solutions before asking questions and that seemed to be the suggested way. Now I have explicitly looked ad xmodmap and it seems sufficient indeed.
    – saroele
    Commented Feb 16, 2017 at 9:42

1 Answer 1

1

Trying to write xkb files is difficult, use xmodmap instead.

The standard name from where to automatically load a mapping on login is ~/.Xmodmap, some display managers do this out of the box, for some display managers you have to modify the login scripts.

Don't try to use xmodmap explictily in .profile or similar, this will give you trouble if you log in via ssh etc.

Edit: As explained in man xmodmap, you can't describe keycode combinations with Alt this way, only with Shift and with the Mode_Switch key:

Up to eight keysyms may be attached to a key, however the last four are not used in any major X server implementation. The first keysym is used when no modifier key is pressed in conjunction with this key, the second with Shift, the third when the Mode_switch key is used with this key and the fourth when both the Mode_switch and Shift keys are used.

For my keyboard, I've assigned Mode_Switch to the left Windows-Key (which happens to be Super_L on my keyboard);

keysym Super_L = Mode_switch

So either designate some key you don't use otherwise as Mode_Switch, or read up on how xkbd words. The Unreliable Guide to XKB Configuration may help.

8
  • With xmodmap I can easily map the Insert key to either Home or End but not both. Even by putting keycode 118 = Home End End End End End all combinations with the Insert key will only do Home.
    – saroele
    Commented Feb 23, 2017 at 15:39
  • I just did xmodmap -e 'keycode 118 = Home End' on my machine, tested with xev, and it works fine. How did you exactly try to load your modification?
    – dirkt
    Commented Feb 23, 2017 at 20:01
  • When I run your command, Home works, but not End. I tried with all possible modifiers (shift, ctrl, alt, + combinations of those). It will always act as Home.
    – saroele
    Commented Feb 23, 2017 at 20:20
  • For me, it works with Shift as modifier. What is your modifier assignment? (Update question with output of xmodmap -pm). Also do modmap -pke | grep 118 to verify that you set the keysyms correctly.
    – dirkt
    Commented Feb 23, 2017 at 20:23
  • Also, look closely at the output of xev when you press the newly configured Shift-Insert. If you get any FocusOut events, or some other events that look fishy, some application or the window manager is stealing this key event.
    – dirkt
    Commented Feb 23, 2017 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .