Keyshorts - bakkeby/dusk GitHub Wiki

Keyshorts is more of a conceptual idea of having a single keybinding (e.g. Super+Tab) which then opens a cheat sheet listing e.g. keyboard shortcuts or other documentation for the currently focused program.

Hitting the key combination a second time hides the cheat sheet.

The best (and simplest) solution I have found so far is to use PDF files that are opened in fullscreen.

The program I use to open the PDF file is evince, and there are a few benefits using this:

  • you can specify the WM_CLASS and instance from the command line
  • you can pass a flag to make it start fullscreen
  • you can use ctrl+f to search through the document
  • when opening the PDF a second time evince remembers how far you had scrolled down and will resume from there making for a very seamless experience

While I may have preferred not to have any UI decorations the top bar is not that distracting and has some useful information.

The way it works is that it will get the WM_CLASS of the currently focused window, let's say "kwrite", and then it is going to check if there exists a file ~/.config/keyshorts/kwrite.pdf and if so it will open it using evince.

evince will run with the WM_CLASS of "keyshorts", such that if the script runs and a window with that particular class exists then the script is going to kill that window and exit (effectively closing the cheat sheet).

I found PDF to be a good option because many programs offer a PDF download of the documentation, and when not selecting text from a web page and use the print to PDF option generally gives reasonable results.

Setup

Dependencies:

  • xdotool
  • evince
  • xkill
  • xprop

To set this up you will need:

Example sxhkd keybinding:

super + Tab
    ~/bin/keyshorts.sh

Example dusk keybinding:

{ KeyPress, Super, XK_Tab, spawn, CMD("~/bin/keyshorts.sh") }, // spawn keyshorts

Early variants of this idea was to have a PNG image with a blurred transparent background that would be opened using pqiv passing arguments to make the background transparent and to hide the info box - i.e. show the image and only the image. This would be similar to the help overlay in GNOME. The idea was also isolated to showing the keyboard shortcuts of the window manager only.

I was also considering generating the image using some of the comprehensive image libraries in Python.

Later ideas also involved using farbfeld tools to generate a help image programatically. In both cases this was more driven by an interest in learning, but in practice it was more effort than it was worth to generate an image for this purpose.


Back to Other scripts and life hacks.

⚠️ **GitHub.com Fallback** ⚠️