8000 Lookup · keyleds/keyleds Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Julien Hartmann edited this page Sep 25, 2017 · 4 revisions

A lookup is a set of conditions used to enable a profile in the configuration file.

Syntax

Lookups take the form of a dictionary of conditions inside a profile, for instance:

some-profile:
    lookup:
        class: kate
        title: ".* [*] .*"

Each lookup defines one regular expression that will be matched against current session context. Available keys are listed below. The full supported syntax is described in the link, but here is a quick summary:

  • Regular characters match themselves: foo matches string foo.
  • . matches a single character.
  • * makes previous match a “zero-or-more” match: ba*r matches br, bar, baar, baaar, …
  • + makes previous match a “one-or-more” match: ba+r matches bar, baar, baaar, … but not br.
  • ? makes previous match optional (“zero-or-one”): ba?r matches br and bar and nothing else.
  • Parenthesizes build groups for use with other operators: (ba)+r matches bar, babar, bababar, …
  • Square brackets match a set of characters: foo[abc1-3] matches fooa, foob, fooc, foo1, foo2 and foo3.

There is much more to it, have a look at the full reference.

Lastly, the match must be complete: foo matches exactly foo, not barfoo, foobar or barfoobar. If you need partial matches, prepend or append .* to your pattern.

Lookup Types

This list should increase as new features are added. As of now, the following lookups can be defined:

  • class: matches active window class, as defined by the application. This is the most useful, as applications often change their title to show additional information (such as current path, open file, etc.), but never change their window class.
  • instance: application instance. Usually the name of the command used to start the application, but many applications allow it to be changed on the command line. For instance, all GTK and Qt-based applications accept a --name argument to set instance name.
  • name: matches active window title. On the technical side, it is _NET_WM_NAME, falling back to WM_NAME if not defined.
  • id: matches active window id. Not too useful, except for value 0 (no active window). Mostly used internally to detect switches between similar windows.

It is also possible to add custom lookups to control the behavior of the service through DBus for scripting.

Finding Out Lookups

The best way to find out what lookup values you can use is to start the service in verbose mode:

killall keyledsd    # shutdown service if it is running
keyledsd -vv

The service will then display every context change on its log output. Look for lines like this one:

<I>service: setContext (class=konsole, id=111149057, instance=konsole, title=build : keyledsd — Konsole)

Those are the values that can be used in lookups.

Examples

Match Kate text editor:

lookup:
    class: kate

Match Kate text editor, but only if current document has unsaved changes:

lookup:
    class: kate
    name: ".* [*] — Kate"

Match chromium browser displaying GMail:

lookup:
    class: [Cc]hromium.*
    name: ".* Gmail - Chromium"

Match KDE screensaver (taking advantage of the fact it's one of the rare applications that sets no class):

lookup:
    class: ^$
Clone this wiki locally
0