Numpad hotkeys on linux: Difference between revisions
From Lucca's Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
You can force X11 to ignore specific keyboards by adding a file to /etc/X11/xorg.conf.d/22-ignorethisdevice.conf: | You can force X11 to ignore specific keyboards by adding a file to /etc/X11/xorg.conf.d/22-ignorethisdevice.conf: | ||
Section "InputClass" | Section "InputClass" | ||
Identifier "DisableGearHeadNumpad" | Identifier "DisableGearHeadNumpad" | ||
MatchIsKeyboard "on" | MatchIsKeyboard "on" | ||
MatchUSBID "04d9:1503" | MatchUSBID "04d9:1503" | ||
Option "Ignore" "true" | Option "Ignore" "true" | ||
EndSection | EndSection | ||
I've created a script to handle keys pressed by a specific numpad: | I've created a script to handle keys pressed by a specific numpad: | ||
#!/bin/bash | #!/bin/bash | ||
keyd monitor | | keyd monitor | | ||
while | while | ||
read; | |||
do | |||
if echo "$REPLY" | fgrep "04d9:1503:20f521c9"; then | |||
if echo "$REPLY" | fgrep "kp0 down"; then echo "this is button 0"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp1 down"; then echo "this is button 1"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp2 down"; then echo "this is button 2"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp3 down"; then echo "this is button 3"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp4 down"; then echo "this is button 4"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp5 down"; then echo "this is button 5"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp6 down"; then echo "this is button 6"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp7 down"; then echo "this is button 7"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp8 down"; then echo "this is button 8"; | |||
fi | |||
if echo "$REPLY" | fgrep "kp9 down"; then echo "this is button 9"; | |||
fi | |||
if echo "$REPLY" | fgrep "numlock down"; then echo "this is button numlock"; | |||
~/sh/rmctrl/commands/lightoff | |||
fi | |||
if echo "$REPLY" | fgrep "kpslash down"; then echo "this is button /"; | |||
~/sh/rmctrl/commands/lighton | |||
fi | |||
if echo "$REPLY" | fgrep "kpasterisk down"; then echo "this is button *"; | |||
~/sh/rmctrl/commands/monitoroff | |||
fi | |||
if echo "$REPLY" | fgrep "backspace down"; then echo "this is button backspace"; | |||
~/sh/rmctrl/commands/monitoron | |||
fi | |||
fi | fi | ||
done | |||
done | |||
Line 66: | Line 63: | ||
<hr> | |||
You could also xmodmap, but it has issues with hotplugging. You can use it like this: | You could also xmodmap, but it has issues with hotplugging. You can use it like this: | ||
Revision as of 19:22, 12 August 2025
Making numpad hotkeys on linux is a bit more tricky than it is on windows due to the critical lack of autohotkey
keyd is an excellent way to make hotkeys:
You can force X11 to ignore specific keyboards by adding a file to /etc/X11/xorg.conf.d/22-ignorethisdevice.conf:
Section "InputClass" Identifier "DisableGearHeadNumpad" MatchIsKeyboard "on" MatchUSBID "04d9:1503" Option "Ignore" "true" EndSection
I've created a script to handle keys pressed by a specific numpad:
#!/bin/bash keyd monitor | while read; do if echo "$REPLY" | fgrep "04d9:1503:20f521c9"; then if echo "$REPLY" | fgrep "kp0 down"; then echo "this is button 0"; fi if echo "$REPLY" | fgrep "kp1 down"; then echo "this is button 1"; fi if echo "$REPLY" | fgrep "kp2 down"; then echo "this is button 2"; fi if echo "$REPLY" | fgrep "kp3 down"; then echo "this is button 3"; fi if echo "$REPLY" | fgrep "kp4 down"; then echo "this is button 4"; fi if echo "$REPLY" | fgrep "kp5 down"; then echo "this is button 5"; fi if echo "$REPLY" | fgrep "kp6 down"; then echo "this is button 6"; fi if echo "$REPLY" | fgrep "kp7 down"; then echo "this is button 7"; fi if echo "$REPLY" | fgrep "kp8 down"; then echo "this is button 8"; fi if echo "$REPLY" | fgrep "kp9 down"; then echo "this is button 9"; fi if echo "$REPLY" | fgrep "numlock down"; then echo "this is button numlock"; ~/sh/rmctrl/commands/lightoff fi if echo "$REPLY" | fgrep "kpslash down"; then echo "this is button /"; ~/sh/rmctrl/commands/lighton fi if echo "$REPLY" | fgrep "kpasterisk down"; then echo "this is button *"; ~/sh/rmctrl/commands/monitoroff fi if echo "$REPLY" | fgrep "backspace down"; then echo "this is button backspace"; ~/sh/rmctrl/commands/monitoron fi fi done
You could also xmodmap, but it has issues with hotplugging. You can use it like this:
xmodmap -e 'keycode 90 = Hyper_R'
You can use XCape to allow the modifier keys to send actions on their own.
sudo apt install xcape xcape -e 'Hyper_R=0'
I've started work on porting my numpad hotkey script to python so it can work on linux: clipboardbuffers.py