Skip to main content

A Linux universal keybindings helper written in Python/QT5

Project description

Kebihelp - The Universal Linux Key Bindings Helper

Kebihelp is an universal key-bindings helper for Linux, written in Python and initially inspired by AwesomeWM and its "Mod4+s" feature.

Click on the picture to zoom.

In this demo:

  • displays the helper
  • key is used to cycle through the tabs.
  • or is used to close it

Features

  • Facilities to import shortcuts from text files or QuickRef
  • Organize shortcuts with Tabs and Groups
  • Customizable design (colors, opacity, fonts, etc.)
  • Configuration in a single JSON file
  • Window Rules supported, to show the shortcuts for the current focused app

Usage

The code is a Python 3 script using PyQT5. You just need to clone this repository and run pip3 install -r requirements.txt.

Then you have to launch kebihelp.py with the relevant options. The tool has 5 main commands:

  • import to import a file containing shortcuts
  • list to show the keybindings configured (console mode)
  • show to show the keybindings configured (GUI mode)

For each command, you can type kebihelp.py <command> -h to get help.

The configuration file is stored in ~/.config/kebihelp.json, which is a JSON file. You can add/modify your shortcuts there.

When the helper is launched with the ./kebihelp.py show, you can navigate through the tabs with the <TAB> key. The helper is closed with the <ESC> or q key.

Importing keybindings

Instead of entering manually each keybinding, you can import them from text files or from Quickref

The syntax to import is as follows:

kebihelp import -t <destination_tab> -s <path>
  • If the path is an URL starting with https://quickref.me/, the corresponding Quickref keybindings will be imported.
  • If the path is a local directory, all files will be analyzed recursively to search for keybindings to add, according to the following syntax:
::Group name::Key binding::Description::

Example:

kebihelp import -t Nvim -s ~/.config/nvim/

These can be anywhere in your various files. Example for Nvim:

You can also create a text file anywhere with your keybindings. This is what I did to register key bindings for Yazi (a command-line file manager):

Once imported, you can reorganize or modify the imported keybindings by editing the $HOME/.config/kebihekp.json file.

Customizing the format of keybindings

In the configuration file kebihelp.json, you are free to change the format of Keybindings. The default configuration is as follows:

    "importer": {
      "match_line": ".*::(.+?)::(.+?)::(.+?)::.*",
      "position_group": 1,
      "position_keybinding": 2,
      "position_label": 3
    },

Displaying keybindings (CLI)

The command kebihelp list will show all keybindings in your terminal.

You can also filter the list by using the option -t <tab name> to show only the keybindings for a particular tab.

Example:

# Show only Hyprland keybindings
kebihelp list -t Hyprland

Displaying keybindings (GUI)

To show a window with all keybindings, just type kebihelp show.

If you use a tiling window-manager, it's recommended to add a rule to set this window in floating mode.

Once displayed, you can navigate through the tabs by using the <TAB> key, and you can close the window using the <Esc> or q key.

The show command accepts also the option -t <tab> to display directory a particular tab instead of the default one.

Rules

In the kebihelp.json file, you can define rules to show a particular tab depending of the current focus. For instance, if you are in a Nvim session and you launch Kebihelp with a keybinding, it will show directly the "Nvim" keybindings.

Example:

 "Rules": {
    "_default": "Hyprland",
    "NVIM": "NeoVim"
  },

Here, the default tab will be the keybindings for Hyprland. However, if you are in NVIM (eg the class/title of your current window contains the text "NVIM"), it will show the tab NeoVim.

To determine the current focused Window name, Kebihelp uses a command that you'll have to define in the Parameters. The command you set up should return one single line with the information you want.

Example:

{
  "Parameters": {
    "cmd_focused_window": "hyprctl -j activewindow | jq '.class + \" - \" + .title'",
  }
}

Here, the current focused window name is determined with hyprctl (Hyprland CLI tool), and then the class and title of the window will be shown.

Hiding tabs, groups or keybindings

Instead of removing them entirely from your kebihelp.json, you can hide a tab, a group or a particular keybinding by setting up the _hidden key to true. Once set up, the tab, group or keybinding will not be shown anymore in the GUI.

Customizing the GUI

You can configure the visual aspect of the GUI helper:

  • Font name and size of any part
  • Colors

To do that, edit the kebihelp.json config file.

Feedbacks

This tool is not perfect, but it may be useful to build your own "keybinding helper" if your Desktop Environment does not support this feature. Your contributions are welcomed!

"Buy Me A Coffee"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kebihelp-0.1.0.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

kebihelp-0.1.0-py3-none-any.whl (10.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page