terminator icon indicating copy to clipboard operation
terminator copied to clipboard

Not all Numpad keys works with Plug-In CustomCommandsMenu

Open nerun opened this issue 1 year ago • 5 comments

Describe the bug Numpad keys /, *, -, + and Enter, doesn't work when CustomCommandsMenu plug-in is enabled.

To Reproduce Just checkbox CustomCommandsMenu plug-in in settings and try to use numpad keys listed above.

Desktop:

  • Linux Debian Trixie (Testing)
  • Terminator 2.1.4
  • Display Technology: X11

nerun avatar Jul 28 '24 00:07 nerun

I have the same problem.

Desktop:

Linux Fedora 40 Desktop Terminator 2.1.4 Display Technology: Wayland

JerryPenguin avatar Jul 28 '24 16:07 JerryPenguin

I had the same issue, and thanks to this issue I figured out it was the CustomCommandsMenu plugin. for me, the only key that isn't working is the Enter (Numpad) I managed to fix it, but I'll show you the process I did with ChatGPT so you can also test out other keys that isn't working.

The issue happened because the CustomCommandsMenu plugin intercepts all key presses, so it is preventing certain keys from reaching the terminal.

Debugging Process

  1. Looking for the default plugins folder path
locate -i terminator

in my case, terminator was installed using apt install terminator on kali (debian) box, so the path is: /usr/lib/python3/dist-packages/terminatorlib/plugins/

  1. Open custom_commands.py with text editor and look for the on_keypress function (line 156)
  2. Let's add a simple print() to print any key pressed, on the very first line:
print(f"Key pressed: keyval={event.keyval}, state={event.state}")

image

  1. Run terminator and press the key that isn't working for you. Here I'm pressing Enter key 4 times IMPORTANT: open terminator from another terminal in order to see the print's. i opened it from QTerminal

image

Solution

Modifying the on_keypress method to explicitly ignore keyval=65421 by returning False when this key is detected.

if event.keyval == 65421:
        return False

image

DrorDvash avatar Jan 04 '25 23:01 DrorDvash

@DrorDvash, you are such a genius!!! This fixed the issue for me.

Debian testing / Trixie: /usr/lib/python3/dist-packages/terminatorlib/plugins/custom_commands.py:

def on_keypress(self, widget, event):
  # DEBUG: print raw keyval
  #print(f"Key pressed: keyval={event.keyval}, state={event.state}")
  # END DEBUG
  bugged_keys = (65421, 65450, 65451, 65453, 65455) #  NumPad: ENTER, *, + , -, /
  if event.keyval in bugged_keys:
      return False

nerun avatar Jan 05 '25 14:01 nerun

Recently Debian updated Terminator and I needed to apply those changes again. So I made a script:

#!/bin/zsh
clear

file="/usr/lib/python3/dist-packages/terminatorlib/plugins/custom_commands.py"
target="def on_keypress(self, widget, event):"

echo -e "\e[93mBefore:\e[0m"
grep -n -A7 $target $file

line=$(grep -n $target $file | cut -d' ' -f1 | sed 's/://')
line=$(( $line + 1 ))

sed -i "${line}i\      # NumPad fix: ENTER, *, + , -, /\n      bugged_keys = (65421, 65450, 65451, 65453, 65455)\n      if event.keyval in bugged_keys:\n          return False\n" $file

echo -e "\n\e[93mAfter:\e[0m"
grep -n -A11 $target $file

Replace #!/bin/zsh by whatever shell you use.

I tried first with head -156 $file + insert lines + tail +157 $file but apparently head and tail do not respect literal \n and this changed some things within the script that should not have been changed.

This script works.

nerun avatar Jan 20 '25 14:01 nerun

Should be an easy fix. Once I'm done triaging

mattrose avatar Jul 08 '25 13:07 mattrose