How to remap a Media key which wrongly restarts the X server

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
ThePhi
Level 1
Level 1
Posts: 21
Joined: Sat Sep 23, 2017 4:46 am

How to remap a Media key which wrongly restarts the X server

Post by ThePhi »

Hi!
I've got a Logitech K200 Keyboard with 8 media keys at the top. Among them, the raising and lowering volume buttons are working great by default, but some of them, like the one with the calculator icon, do not.
For example, the one with the calculator restarts the X server!

So it was very difficult to find which keycode was linked to that key (since it immediately restarts the X server)... but I managed to do that by using a non-GUI environment (Ctrl+Alt+F2) and running `showkey`. Thus, I found that the keycode linked to that key was 140.
How can I remap this key then?
I can't use the GUI settings because it tells me to press the key to bind, and then it restarts the X server, as noted above!

I tried xmodmap with .Xmodmap like this:
`keycode 140 = XF86AudioMute` as a test (I got a mute media key and I already know that this XF86 action is working).
But it still restarts the X server!

Thanks
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: How to remap a Media key which wrongly restarts the X server

Post by Koentje »

If you try this example on the terminal, does that work?
xmodmap -e "keycode 140 = Delete"

btw, have you tried xev > ~/xev.dump and see what the last keypress was in the file?
Image
ThePhi
Level 1
Level 1
Posts: 21
Joined: Sat Sep 23, 2017 4:46 am

Re: How to remap a Media key which wrongly restarts the X server

Post by ThePhi »

Thanks for your answer. :)
No, it doesn't change anything, the key still restarts X.

This is the dump from xev: The key doesn't seem to be recorded, because the X server restarts even before it can write to the file (that's my guess).
But I already know that the key has keycode 140 as I mentioned in the post above.

Code: Select all

Outer window is 0x2200001, inner window is 0x2200002

PropertyNotify event, serial 8, synthetic NO, window 0x2200001,
    atom 0x27 (WM_NAME), time 66730310, state PropertyNewValue

PropertyNotify event, serial 9, synthetic NO, window 0x2200001,
    atom 0x22 (WM_COMMAND), time 66730310, state PropertyNewValue

PropertyNotify event, serial 10, synthetic NO, window 0x2200001,
    atom 0x28 (WM_NORMAL_HINTS), time 66730310, state PropertyNewValue

CreateNotify event, serial 11, synthetic NO, window 0x2200001,
    parent 0x2200001, window 0x2200002, (10,10), width 50, height 50
border_width 4, override NO

PropertyNotify event, serial 14, synthetic NO, window 0x2200001,
    atom 0x145 (WM_PROTOCOLS), time 66730310, state PropertyNewValue

MapNotify event, serial 15, synthetic NO, window 0x2200001,
    event 0x2200001, window 0x2200002, override NO

ConfigureNotify event, serial 24, synthetic NO, window 0x2200001,
    event 0x2200001, window 0x2200001, (0,0), width 178, height 178,
    border_width 0, above 0x3a00376, override NO

PropertyNotify event, serial 28, synthetic NO, window 0x2200001,
    atom 0x1e9 (_NET_WM_ALLOWED_ACTIONS), time 66730311, state PropertyNewValue

ReparentNotify event, serial 29, synthetic NO, window 0x2200001,
    event 0x2200001, window 0x2200001, parent 0x200ffe5,
    (0,0), override NO

PropertyNotify event, serial 29, synthetic NO, window 0x2200001,
    atom 0x14a (_NET_FRAME_EXTENTS), time 66730317, state PropertyNewValue

ConfigureNotify event, serial 29, synthetic NO, window 0x2200001,
    event 0x2200001, window 0x2200001, (10,45), width 178, height 178,
    border_width 0, above 0x0, override NO

PropertyNotify event, serial 29, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730318, state PropertyNewValue

PropertyNotify event, serial 31, synthetic NO, window 0x2200001,
    atom 0x14d (_NET_WM_DESKTOP), time 66730318, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x2200001,
    atom 0x17d (WM_STATE), time 66730364, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x2200001,
    atom 0x153 (_NET_WM_STATE), time 66730364, state PropertyNewValue

PropertyNotify event, serial 32, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730364, state PropertyNewValue

PropertyNotify event, serial 34, synthetic NO, window 0x2200001,
    atom 0x17e (XKLAVIER_STATE), time 66730367, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730371, state PropertyNewValue

ConfigureNotify event, serial 35, synthetic YES, window 0x2200001,
    event 0x2200001, window 0x2200001, (125,162), width 178, height 178,
    border_width 2, above 0x0, override NO

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730384, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x153 (_NET_WM_STATE), time 66730384, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730384, state PropertyNewValue

MapNotify event, serial 35, synthetic NO, window 0x2200001,
    event 0x2200001, window 0x2200001, override NO

VisibilityNotify event, serial 35, synthetic NO, window 0x2200001,
    state VisibilityUnobscured

Expose event, serial 35, synthetic NO, window 0x2200001,
    (0,0), width 178, height 10, count 3

Expose event, serial 35, synthetic NO, window 0x2200001,
    (0,10), width 10, height 58, count 2

Expose event, serial 35, synthetic NO, window 0x2200001,
    (68,10), width 110, height 58, count 1

Expose event, serial 35, synthetic NO, window 0x2200001,
    (0,68), width 178, height 110, count 0

FocusIn event, serial 35, synthetic NO, window 0x2200001,
    mode NotifyNormal, detail NotifyNonlinear

KeymapNotify event, serial 35, synthetic NO, window 0x0,
    keys:  100 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x153 (_NET_WM_STATE), time 66730388, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730388, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x153 (_NET_WM_STATE), time 66730388, state PropertyNewValue

PropertyNotify event, serial 35, synthetic NO, window 0x2200001,
    atom 0x17c (_GTK_EDGE_CONSTRAINTS), time 66730388, state PropertyNewValue

FocusOut event, serial 35, synthetic NO, window 0x2200001,
    mode NotifyGrab, detail NotifyAncestor
Post Reply

Return to “Beginner Questions”