KWin Rules

From KDE UserBase Wiki

Overview

KWin allows the end-user to define rules to alter the behavior of an application's windows.

For example, when an application is started, it can be forced to always run on Virtual Desktop #2. Or a defect in an application can be worked-around by using a rule to, say, always force the window on top of all others.

This page will define the different settings and the attributes. For the impatient folks, working examples will be listed. Whenever possible, screen shots will be used to show example settings.

Tip

Panels can also be affected.


Examples

Force a Window on a Desktop

Force a Window on all Desktops

Suppress a Window showing on Pager

Force a Window to the Top

Good for knotes

Multiple Rules per Application

e.g. Thunderbird on one desktop and composition window on any

Pop Active Window to the Front/Top

KWin Rule Editor

Invoking the Editor

There are several ways one can invoke the Rules editor. Below are a couple:

  • Right-click on the title-bar of any window, choose Configure Window Behavior ... and in the Configure window, select Window Rules or
  • Configure Desktop -> Window Behavior -> Window Rules

Anatomy

The editor is composed of four tabs:

  1. Window matching
  2. Size & Position
  3. Arrangement & Access
  4. Appearance & Fixes

As the name implies, Window matching is used to specify criteria to match one or more windows. The other three tabs are used to alter the characteristics of the matching windows.

Rules

Evaluation

KWin evaluates the rules when an application starts and after editing rules. Any matching rule's attribute(s) override the application's corresponding attribute(s).

Precedence

In the Window Rules window, the rules are listed in the order in which they are processed.

The rule at the top of the list is processed first, followed by the next rule until the end of the list is reached.

Conflicts

In the event two rules match a window and affect the same attribute, the first rule in the list takes precedence.

Window Matching

The Window Matching tab provides a series of matching-criteria fields used to identify application windows:

  • Window class (application) - match this window and all its children windows.
    • and Match whole window class
  • Window role - restrict the match to the function of the window (e.g. a main window, a chat window, etc.)
  • Window types - restrict the match to the type of window: Normal Window, Dialog Window, etc.
  • Window title - restrict the match to the title of the window.
  • Machine (hostname) - restrict the match to the host name associated with the window.

Tip

While it's possible to manually enter the above information, the preferred method is to use the Detect Window Properties button.


For each field, the following operators can be applied against the field value:

  • Unimportant
  • Exact Match
  • Substring Match
  • Regular Expression - Qt's regular expressions are implemented. For additional information, web search qt regex nokia.
Detect Window Properties

The Detect Window Properties function simplifies the process of entering the matching-criteria.

  1. For the application you'd like to create a rule, start the application.
  2. Next, in the Window matching tab, set the number of seconds of delay before the Detect Window Properties function starts. The default is zero seconds.
  3. Click on Detect Window Properties and
  4. When the mouse-cursor turns to cross-hairs, place it inside the application window and left-click.
  5. A new window is presented with information about the selected window:
    • Class
    • Role
    • Type
    • Title
    • Machine (hostname)

Click the OK button to back-fill the Window Matching criteria.

By using a combination of the information, you can tailor whether a rule applies to an entire application (by Class) or a to a specific window Type within the Class - say a Toolbar.

Window Attributes

The attributes which can be set are grouped in three tabs:

  1. Size & Position
  2. Arrangement & Access
  3. Appearance & Fixes

Each attribute has additional settings which determine when they're applied and depending on the attribute, there may be an additional argument.

Parameters

Each attribute minimally accepts one of the following parameters. Additional, attribute-specific arguments are listed within each attribute definition.

Do Not Affect
Unset the attribute.

Tip

As rules are evaluated from the top of the list to the bottom, a generic rule can be written to default a certain attribute for all windows. Subsequent, restrictive rules can be created to unset the attribute for different windows.
Apply Initially
Start the window with the attribute and allow it to be changed at run-time.
Remember
Use the attribute setting as defined in the rule and if changed at run-time, save and use the new value instead.
Force
The setting cannot be changed at run-time.
Apply Now, Force Temporarily
Apply/Force the setting once and unset the attribute.

Warning

If the rule has not other attributes set, the rule is deleted.


Attributes

Tip

Using Detect Window Properties back-fills values for attributes. For example the height and width arguments of the Size attribute is set to the height and width of the detected window.

Tip

Yes/No arguments are used to toggle attributes. For example, if a window's default behavior is to start horizontally maximized and you wish to disable this behavior, specify No as the argument to Maximized horizontally, on the other hand if you wish to force a window to start horizontally maximized, specify Yes.


Size & Position
Position
Position the window's upper left corner at the specified x,y coordinate.

Tip

KWin's origin, (0,0), is the upper left.
Size
The width and height of the window.
Maximized horizontally, Maximized vertically, Fullscreen
These attributes are used to toggle the maximum horizontal/minimum horizontal/full-screen window attribute.
Desktop
Place the window on the specified (Virtual) Desktop. Use All Desktops to place the window on all Virtual Desktops.
Minimized, Shaded
Toggle the Minimize and Shading window attribute. For example, a window can be started Minimized or if it is started Minimized, it can be forced to not.

Tip

Maximized attribute is emulated by using both Maximized horizontally and Maximized vertically or Initial placement with the Maximizing argument.
Initial placement
Override the global window placement strategy with one of the following:
  • Default - use the global window placement strategy.
  • No Placement - top-left corner.
  • Smart - place where no other window exists.
  • Maximizing - start the window maximized.
  • Cascade
  • Centered
  • Random
  • Top-Left Corner
  • Under Mouse
  • On Main Window - restrict placement of a child window to the boundaries of the parent window.
Ignore requested geometry
Toggle whether to accept or ignore the window's requested geometry and ignore the global placement strategy.
Minimum size, Maximum size
The minimum and maximum size allowed for the window.
Obey geometry restrictions
Toggle whether to adhere to the window's requested aspect ratio.
Arrangement & Access
Keep above, Keep below
Toggle whether to keep the window above/below all others.
Autogroup with identical
Toggle the grouping (commonly known as tabbing) of windows.
Autogroup in foreground
Toggle whether to make the window active when it is added to the group.
Autogroup by ID
Create a group via a user-defined ID. More than one rule can share the same ID to allow for seemingly unrelated windows to be grouped.
Tiling
Override the default window behavior to either Tiled or Floating.
Skip taskbar
Toggle whether to display the window in the taskbar.
Skip pager
Toggle whether to display the window in the virtual desktop list.
Skip switcher
Toggle whether to display the window in the ALT+TAB list.
Shortcut
Assign a shortcut to the window. When Edit... is clicked, additional instructions are presented.
Appearance & Fixes
No titlebar and frame
Toggle whether to display the titlebar and frame.
Active/Inactive opacity
When the window is active/inactive, set its opacity to the percentage specified.

Tip

Active/Inactive opacity can only be affected when Desktop Effects are enabled.
Moving/resizing
Deprecated as of >4.8
Focus stealing prevention
When a window wants focus, control on a scale (from None to Extreme) whether to honor the focus request and place the window on top above all other windows and give it focus, or ignore its request (potentially leaving the window behind other windows).
  • None - Always grant focus to the window.
  • Low
  • Normal
  • High
  • Extreme - The window's focus request is denied. Focus is only granted by mousing to the window.

Tip

See Accept focus to make a window read-only - not accept any keyboard input.
Accept focus
Toggle whether the window accepts keyboard input. Make the window read-only.
Ignore global shortcuts
Toggle whether to ignore global shortcuts while the window is active.
Closeable
Toggle whether to display the Close button on the title bar.

Tip

A terminal window may still be closed by the end user by ending the shell session however using Accept focus to disable keyboard input will make it more difficult to close the window.
Window type
Change the window to another type and inherit the characteristics of that window:
  • Normal Window
  • Dialog Window
  • Utility Window
  • Dock (panel)
  • Toolbar
  • Torn-Off Menu
  • Splash Screen
  • Desktop
  • Standalone Menubar
Block compositing
Toggle whether to disable compositing while the window exists. If compositing is enabled and the rule specifies to disable compositing, once the window exists, compositing will be re-activated.