Numpad hotkeys on linux: Difference between revisions

From Lucca's Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
Making numpad hotkeys on linux is a bit more tricky than it is on windows due to the critical lack of autohotkey
Making numpad hotkeys on linux is a bit more tricky than it is on windows due to the critical lack of autohotkey
<hr>


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:


You'll need xmodmap, you can use it like this:
Section "InputClass"
    Identifier "DisableGearHeadNumpad"       
    MatchIsKeyboard "on"
    MatchUSBID "04d9:1503"
    Option "Ignore" "true"
EndSection


<code>xmodmap -e 'keycode 90 = Hyper_R'</code>


You can use XCape to allow the modifier keys to send actions on their own.
I've created a script to handle keys pressed by a specific numpad:
  sudo apt install xcape
 
  xcape -e 'Hyper_R=0'
#!/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:


keyd is an excellent way to make hotkeys as well.
xmodmap -e 'keycode 90 = Hyper_R'


You can use XCape to allow the modifier keys to send actions on their own.


I've started work on porting my numpad hotkey script to python so it can work on linux: [[clipboardbuffers.py]]
sudo apt install xcape
xcape -e 'Hyper_R=0'




<hr>
I've started work on porting my numpad hotkey script to python so it can work on linux: clipboardbuffers.py
Resources
<hr>
https://wiki.archlinux.org/title/Xmodmap#Installation
https://github.com/alols/xcape
https://github.com/rvaiya/keyd
https://lars.ingebrigtsen.no/2024/04/28/the-simplest-thing-in-the-world-modifing-keymaps-in-wayland/

Revision as of 19:20, 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:

  1. !/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