-
Notifications
You must be signed in to change notification settings - Fork 31
Lookup
A lookup is a set of conditions used to enable a profile in the configuration file.
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 stringfoo
. -
.
matches a single character. -
*
makes previous match a “zero-or-more” match:ba*r
matchesbr
,bar
,baar
,baaar
, … -
+
makes previous match a “one-or-more” match:ba+r
matchesbar
,baar
,baaar
, … but notbr
. -
?
makes previous match optional (“zero-or-one”):ba?r
matchesbr
andbar
and nothing else. - Parenthesizes build groups for use with other operators:
(ba)+r
matchesbar
,babar
,bababar
, … - Square brackets match a set of characters:
foo[abc1-3]
matchesfooa
,foob
,fooc
,foo1
,foo2
andfoo3
.
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.
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 toWM_NAME
if not defined. -
id
: matches active window id. Not too useful, except for value0
(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.
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.
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: ^$