Numpad hotkeys on linux: Difference between revisions

From Lucca's Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 57: Line 57:




...and a systemd service to autostart it: [/home/lucka/.config/systemd/user/numpadhotkeys.service]
...and a systemd service to autostart it: [<code>/home/lucka/.config/systemd/user/numpadhotkeys.service</code>]


  [Unit]
  [Unit]
Line 73: Line 73:
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:


xmodmap -e 'keycode 90 = Hyper_R'
xmodmap -e 'keycode 90 = Hyper_R'


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


sudo apt install xcape
sudo apt install xcape
xcape -e 'Hyper_R=0'
 
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
I've started work on porting my numpad hotkey script to python so it can work on linux: clipboardbuffers.py

Latest revision as of 00:43, 15 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


...and a systemd service to autostart it: [/home/lucka/.config/systemd/user/numpadhotkeys.service]

[Unit]
Description=Script that handles numpad hotkeys

[Service]
ExecStart=/home/lucka/sh/numpad-hotkeys-keyd.sh
Restart=on-failure

[Install]
WantedBy=default.target



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