You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Controlling i3 Workspaces and Executing Shell Commands with an External USB Numpad
Hello everyone,
I've been working on a Python script that allows me to use an external generic USB numpad to control various functions in i3 and execute shell commands. I thought I'd share it here in case anyone else finds it useful.
It's configured using a YAML file, which maps keys on the numpad to commands or functions.
You also have the ability to set window-specific shortcuts. These are only activated when a specific window is in focus. The window matching can be done based on the start, end, or any part of the window name, or an exact match.
Here's an example of the configuration file shortcuts.yaml:
In this example, pressing the keys from KEY_KP1 to KEY_KP9 and KEY_KP0 on the numpad will switch to workspaces 1 to 10 respectively. The KEY_KPMINUS key will perform different actions based on the active window's name.
You can run any command that can be executed in a shell. The command just needs to be specified as a list of strings, where each string is a part of the command. For example, if you want to run the command ls -l, you would add it to the shortcuts.yaml file like this:
KEY_KPPLUS:
- command: ['ls', '-l']
In this case, when you press the KEY_KPPLUS key on your numpad, the ls -l command will be executed. The output of the command will be displayed in the terminal where you are running the numpad.py script.
To run the script, you'll need to install the required Python packages. You can do this by running pip install -r requirements.txt in your terminal. Then, simply run the script with python numpad.py.
You can find the Python script and the configuration file in my GitHub Gist.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Title: Controlling i3 Workspaces and Executing Shell Commands with an External USB Numpad
Hello everyone,
I've been working on a Python script that allows me to use an external generic USB numpad to control various functions in i3 and execute shell commands. I thought I'd share it here in case anyone else finds it useful.
It's configured using a YAML file, which maps keys on the numpad to commands or functions.
You also have the ability to set window-specific shortcuts. These are only activated when a specific window is in focus. The window matching can be done based on the start, end, or any part of the window name, or an exact match.
Here's an example of the configuration file
shortcuts.yaml
:In this example, pressing the keys from
KEY_KP1
toKEY_KP9
andKEY_KP0
on the numpad will switch to workspaces 1 to 10 respectively. TheKEY_KPMINUS
key will perform different actions based on the active window's name.You can run any command that can be executed in a shell. The command just needs to be specified as a list of strings, where each string is a part of the command. For example, if you want to run the command
ls -l
, you would add it to theshortcuts.yaml
file like this:In this case, when you press the
KEY_KPPLUS
key on your numpad, thels -l
command will be executed. The output of the command will be displayed in the terminal where you are running thenumpad.py
script.To run the script, you'll need to install the required Python packages. You can do this by running
pip install -r requirements.txt
in your terminal. Then, simply run the script withpython numpad.py
.You can find the Python script and the configuration file in my GitHub Gist.
I hope someone finds this useful.
Beta Was this translation helpful? Give feedback.
All reactions