Modding the keyboard ? (.Xmodmap file)

Hello ;=)
i was not sure where to start this :
i have a /home/user/.Xmodmap file but it seems it is not working in Leap 15.6 .
It was working in Leap 15.5 so i’m wondering why it is not working anymore .
Thank you :wink:

Xmodmap is for X11. Are you in Wayland on 15.6?

keyd is a WM & DE agnostic alternative.

yes, it’s using wayland now. ( i’m using leap 16.0 actually, i made a mistake above)

can i use such a line in keyd ?

!F12
keycode 96 =  XF86PowerOff NoSymbol XF86PowerOff NoSymbol XF86PowerOff

keyd has its own configuration syntax which is pretty different if you are used to Xmodmap, but it is also much, much more powerful. I really suggest looking at man keyd and on the GitHub to see the kind of possibilities.

If you just want to remap F12 to poweroff, though, then something like this will suffice:

/etc/keyd/default.conf

[ids]

*

[main]

# Maps f12 to the power key
f12 = power

[ids] tells keyd which keyboards to remap, in this case, the wildcard is used for all keyboards.

You will need to make /etc/keyd/default.conf yourself, it’s not added by keyd.

Also, after setting up the configuration, start the keyd service with sudo systemctl enable keyd --now and use sudo keyd reload to reload the config after making changes.

Missed the edit window, but one neat trick keyd can do is chording, where pressing multiple keys at the same time can perform an action.

For example, if I want something mapped to power but I don’t want to lose f12 for applications that may use it, I can do something like:

/etc/keyd/default.conf

f11+f12 = power

In this case, pressing f11 or f12 by themselves still functions as f11 or f12, but pressing them at the same time will shutdown the computer.

You can also use keyd to execute console commands with command() which will execute whatever is in the parentheses, but this comes with the big caveat that keyd executes all commands as root, so be very careful with that.

Hello,
i tried with power, it is giving the entire menu this is more complete that what i used , thanks :slight_smile: And quicker too for shutdown is now very quick.

[what i showed above was a bit different, giving directly the power off menu (and there is a countdown of 30 seconds)
]

here is what i was using with x11, not everything was working though, and some keys not mapped on purpose too. not sure what are the equivalents.

!F1
keycode 67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1 F1 F1 XF86Switch_VT_1 F1 F1 F1 F1 XF86Switch_VT_1

!F2
keycode 68 = XF86Mail NoSymbol XF86Mail NoSymbol XF86Mail              

!F3
keycode 69 = XF86Copy NoSymbol XF86Copy NoSymbol XF86Copy

!F4
keycode 70 = XF86Paste NoSymbol XF86Paste NoSymbol XF86Paste

!F5
keycode 71 = XF86Reload NoSymbol XF86Reload NoSymbol XF86Reload

!F6
keycode 72 = XF86Calculator NoSymbol XF86Calculator NoSymbol XF86Calculator

!F7 unused
!keycode 73 = F7 ne pas toucher pour ne pas perdre le retour en mode graphique via ctrl alt F7

!F8
keycode 74 = XF86Search NoSymbol XF86Search NoSymbol XF86Search

!F9
keycode 75 = XF86AudioPlay NoSymbol XF86AudioPlay NoSymbol XF86AudioPlay

!F10
keycode 76 = XF86AudioPause NoSymbol XF86AudioPause NoSymbol XF86AudioPause

!F11 unused 
!keycode 95 = F11 ne pas toucher, pour ne pas perdre F11 boot menu lors de soucis du pc au boot.

!F12
keycode 96 =  XF86PowerOff NoSymbol XF86PowerOff NoSymbol XF86PowerOffou 

i see the interesting of chording to avoid a key being unavailable in x or y soft.

Sorry for the late reply, was away from the computer for a few days.

This page from the author’s GitHub gives the keyd equivalent for various keysyms used in .Xmodmap.

I think something like this config file would do what you want:

/etc/keyd/default.conf

[ids]

*

[main]

# f1 = f1
f2 = mail
f3 = copy
f4 = paste
f5 = refresh
f6 = calc
# f7 = f7
f8 = search
f9 = playpause
f10 = playpause
# f11 = f11
f12 = power

[shift]

# f1 = f1
f2 = f2
f3 = f3
f4 = f4
f5 = f5
f6 = f6
# f7 = f7
f8 = f8
f9 = f9
f10 = f10
# f11 = f11
f12 = f12

In this config [main] remaps function keys to different things like email and calculator (leaving f1, f7 and f11 unchanged). [shift] remaps function keys back to themselves when pressed with shift.

Just a note that while you had f9 and f10 mapped to XF86AudioPlay and XF86AudioPause, respectively, in keyd these are merged into one key playpause, so you could map one of them to something else, if you wanted.

Let me know if you need anymore help with getting keyd running how you like :slight_smile:

Hello, thank you for this.
I don’t know if i will use the shift part but it could be useful so i added it just in case.
Very interesting link indeed :slight_smile:

1 Like

Happy to help!

If you’re satisfied that the issue is resolved, select the reply that shows the solution and mark it as the solution, so that anyone else with a similar question can easily find the answer.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.