Recoll hotkey: starting / hiding recoll with a keyboard shortcut

Type a key (ie: F12) and have recoll appear or disappear. On the first occurrence, recoll is started if it’s not already running. Further occurrences toggle recoll between visible and minimized states. Never thought this would be useful until someone asked for it. Can’t do without it anymore :)

This works well with both Gnome and KDE, but is implemented using a gnome library (libwnck) and its python interface, which you may have to install on your system if you are a pure KDE user. The library most probably exists in the package repositories for your distribution, so this should not be too complicated.

This should also work with other window managers, because it is based on a standard window manager interface extension (EWMH) that most modern window managers implement.

Installing the script (all desktops):

  • You will need the libwnck library and its python interface. These are usually part of a gnome installation, otherwise check and possibly install them. For OpenSuse, the library should already be there but you need to install gnome-python-desktop.

  • Download the https://www.recoll.org/files/hotrecoll.py script. If you have a recent recoll installation (1.14.3 and further), it’s already in the recoll filters directory ('/usr/[local/]share/recoll/filters')

  • Copy the script to some permanent place (ie: '~/bin') and make it executable (you can leave it in the filters dirs if it’s there). In a shell window: chmod +x hotrecoll.py.

  • You can check that the script works (or not) by executing it on the command line. It does not need an argument. Recoll should appear or disappear every time you execute the script. A few warning messages may be considered normal. If the script says that it does not find the wnck library or some other module, you’ll have to install them.

Installing the keyboard shortcut (Gnome):

  • System→Preferences→Keyboard shortcuts, or execute gnome-keybinding-properties

  • Click add, Name, ie: StartRecoll, Action: /path/to/hotrecoll.py

  • This will add the shortcut to the "Custom shortcuts" section. You can then click in the "Shortcut" column for "StartRecoll", and type any key combination (ie: push F12) to assign a key shortcut.

Installing the keyboard shortcut (KDE):

Under KDE installing a global custom keyboard shortcut like we need is most helpfully not under "Keyboard Shortcuts" but under "Input Actions".

  • Kmenu → Configure Desktop → Input Actions → Edit → New → Global Shortcut → Command/Url

  • A new Action appears, named New Action. You can rename it something like hotrecoll for clarity.

  • Click the Trigger tab, click the input area and press your preferred key combination (ie: F12)

  • Click the Action tab, and enter hotrecoll.py (if it’s in your PATH), or else the full path to the command (e.g.: '/usr/share/recoll/filters/hotrecoll.py').

  • Click Apply.

Installing the keyboard shortcut (XFCE):

Open the settings manager, and add the shortcut in the Application Shortcuts panel inside the Keyboard tool.

Other environments

Many window managers have a way to set up a keyboard shortcut for running an arbitrary command. You’ll need to look at the documentation for yours, or search the web for a solution.

An alternative independant of the environment would be to use the XBindKeys utility. See this linux.com article for helpful instructions.