# Window Rules

&Lauri.Watts; &Lauri.Watts.mail;
Parts of this documentation was converted from the KDE UserBase KWin Rules page.
&FDLNotice;
2012-06-02
&kde; SC 4.9

Here you can customize window settings specifically only for some windows.

KDE KControl window settings window placement window size

## Window Specific Settings: Quick Start

Here you can customize window settings specifically only for some windows.

Please note that this configuration will not take effect if you do not use &kwin; as your window manager. If you do use a different window manager, please refer to its documentation for how to customize window behavior.

Many of the settings you can configure here are those you can configure on a global basis in the Window Behavior &systemsettings; module, however some of them are even more detailed.

They encompass geometry, placement, whether a window should be kept above or below others, focus stealing prevention, and translucency settings.

You can access this module in two ways: from the titlebar of the application you wish to configure, or from the &systemsettings;. If you start it from within &systemsettings; you can use the New... to create a window profile, and the Detect Window Properties button on the resulting dialog to partially fill in the required information for the application you wish to configure.

You can also at any time Modify... or Delete any stored settings profile, and reorder the list. Reordering the list using the Move Up and Move Down buttons effects on how they are applied.

## Overview

&kwin; allows the end-user to define rules to alter an application's window attributes.

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 to force the window above others.

Step-by-step examples are provided along with detailed information on using the &kwin; Rule Editor to specify Window Matching and Window Attributes.

## Examples and Application Workaround

To see what's possible, detailed examples are provided which can also be used to model your own rules.

A special page is to dedicated to address Application Workaround.

## KWin Rule Editor

### Invoking the KWin Rule Editor

There are several ways to invoke the &kwin; Rule Editor. Below are two:

- Right-click on the title-bar of any window, choose More Actions Window Manager Settings... and in the Configure window, select Window Rules or

- System Settings Window Behavior Window Rules

The main window is used to:

- Affect rules with New..., Modify... and Delete

- Share rules with others via Import and Export

- Ensure desired rule evaluation using Move Up and Move Down

#### Rule Evaluation

When an application starts (or the rules are modified), &kwin; evaluates the rules from the top of the list to the bottom. For all rules which match a window, the collective set of attributes are applied to the window, then the window is displayed.

Should two or more matching rules enable the same attribute, the setting in the first rule in the list is used.

You can tailor children windows for the application by placing the more restrictive rules first - see the Kopete and Kopete Chat Window example.

### Rule Editor

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 attributes of the matching windows.

Panels can also be affected.

#### Window Matching

Each window rule has user specified Window Matching criteria. &kwin; uses the criteria to determine whether the rule is applicable for an application.

#### Window Attributes

Along with Window Matching criteria, each window rule has a set of Window Attributes. The attributes override the corresponding application's settings and are applied before the window is displayed by &kwin;.

## Window Matching

The Window Matching tab is used to specify the criteria &kwin; uses to evaluate whether the rule is applicable for a given window.

Zero (match any window) or more of the following may be specified:

- Window class (application) - match the class.

  - Match whole window class - include matching the secondary class.

- Window role - restrict the match to the function of the window (⪚ 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.

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 - ignore the field.

- Exact Match

- Substring Match

Both Exact Match and Substring Match implement case insensitive matching. For example, AB matches the string AB, ab, Ab and aB.

- Regular Expression - Qt's regular expressions are implemented - see pattern matching using regular expressions.

### 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 (not the title bar) and left-click.

5. A new window is presented with information about the selected window. Select the desired fields:

   - Secondary class name - some applications have a secondary class name. This value can be used to restrict windows by this value.

   - Window role

   - Window type

   - Window title

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

By using a combination of the information, a rule can apply 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 by function in three tabs:

1. Size & Position

2. Arrangement & Access

3. Appearance & Fixes

Each attribute has a set of parameters which determines its disposition.

### Parameters

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

Do Not Affect

  Ensure a subsequent rule, which matches the window, does not affect the attribute.

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.The difference between the two is at run-time, Apply Now allows the attribute to be changed and Force Temporarily prohibits it to be altered until all affected windows exit.

For Apply Now, if the rule has no other attributes set, the rule is deleted after evaluation whereas Force Temporarily, the rule is deleted after the last affected window terminates.

### Attributes

The Detect Window Properties button back-fills attribute-specific values - for more information see Window Matching. For example the height and width values of the Size attribute is set to the height and width of the detected window.

Yes/No arguments are used to toggle on or off attributes. Leniency with grammar helps one understand how a setting will be processed. For example, the attribute Skip taskbar, when set to No means do not skip the taskbar. In other words, show the window in the taskbar.

#### Size & Position

Position

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

&kwin;'s origin, (0,0), is the upper left of the desktop.

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.

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 - staircase-by-title.

  - Centered - center of the desktop.

  - 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 position. To avoid conflicts between the default placement strategy and the window's request, the placement strategy is ignored when the window's request is accepted.

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 or base increment.In order to understand this attribute, some background is required. Briefly, windows must request from the Window Manager, a base increment: the minimum number of height X width pixels per re-size request. Typically, it's 1x1. Other windows though, for example terminal emulators or editors, use fixed-fonts and request their base-increment according to the size of one character.

#### 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 current Autogroup.

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 pager:

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 around the window.

Active/Inactive opacity

  When the window is active/inactive, set its opacity to the percentage specified.

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 request and place above all other windows, 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 explicitly requesting via the mousing.

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 (as defined by System Settings Shortcuts and Gestures Global Shortcuts or by running `kcmshell4 keys` in konsole) while the window is active.

Closeable

  Toggle whether to display the Close button on the title bar.

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

Use with care because unwanted results may be introduced. For example, a Splash Screen is a automatically closed by &kwin; when clicked.

Block compositing

  Toggle whether to disable compositing while the window exists. If compositing is enabled and the rule specifies to disable compositing, while any matching window exists, compositing will be disabled. Compositing is re-enabled when the last matching window terminates.

## Examples

The first example details all the necessary steps to create the rules. In order to keep this page a manageable size, subsequent examples only list steps specific to the example.

The Pager attribute refers to the Virtual Desktop Manager:

### Pin a Window to a Desktop and set other Attributes

Pin &akregator; to Virtual Desktop 2. Additionally, start the application with a preferred size and position. For each attribute, use the Apply Initially parameter so it can be overridden at run-time.

The &kwin; rule is created as follows:

1. Start &akregator; on desktop two, size and position it to suit:

2. Right-click on the titlebar and select More Actions Window Manager Settings...:

3. Select the Window Rules in the left column and click on New...:

4. The Edit Window-Specific Settings window is displayed. Window matching is the default tab:

5. Click Detect Window Properties with 0s delay the cursor immediately turns into cross-hairs. Click (anywhere) inside the &akregator; window (but not the title bar). The window criteria are presented. Match only by primary class name so leave the check boxes unchecked - for additional information see window matching:

6. Clicking OK the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description field (which is displayed in the KWin Rule window):

7. Enable the window attributes: Position, Size and Desktop. The initial values are set by Detect Window Properties and can be overridden:

8. Clicking OK in the previous window returns to the main KWin Rules. The new rule with its description is listed:

9. Click OK to close the window.

10. Done.

### Application on all Desktops and Handle One Child Window Uniquely

Except for conversation windows, display &kopete; and its children windows on all desktops and skip the systray and pager. For children conversation windows, treat them as the parent window except show them in systray.

For each attribute, use the Force parameter so it can not be overridden.

In order to implement the above, two rules need to be created:

1. A rule for Kopete Chat and

2. A rule for &kopete;

The Kopete Chat rule's matching-criteria is more restrictive than the Kopete rule as it needs to match a specific Window Role: the chat window. Due to rule evaluation processing, the Kopete Chat rule must precede the &kopete; rule in the KWin Rule list for Kopete.

#### Kopete Chat Rule

Assuming a Kopete Chat window is open:

1. Use Detect Window Properties and select the Kopete Chat window. Check the Window role box to restrict the criteria to chat windows - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the following attributes:

4. Click through to complete entry of the rule.

The Skip taskbar attribute is set to No to display the window in the taskbar which loosely translates to: no do not skip taskbar .

#### Kopete Rule

Assuming &kopete; is open:

1. Use Detect Window Properties and select the &kopete; window. Match only by primary class name so leave the check boxes unchecked - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the following attributes:

4. Click through to complete entry of the rule.

#### Kopete KWin Rule List

As mentioned, due to rule evaluation processing, the Kopete Chat rule must precede the &kopete; rule:

### Suppress a Window from showing on Pager

KNotes currently does not allow for its notes to skip the pager however a rule easily solves this shortcoming.

Assuming a sticky note' window is available:

1. Use Detect Window Properties and select any sticky note window. Match only by primary class name so leave the check boxes unchecked - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the Skip Pager attribute with the Force parameter:

4. Click through to complete entry of the rule.

### Force a Window to the Top

To pop an active window to the top, set its Focus stealing prevention attribute to None, typically, in conjunction with the Force parameter:

### Multiple Rules per Application

Thunderbird has several different child windows. This example:

- Pin Thunderbird's main window on Virtual Desktop 1 with a specific size and location on the desktop.

- Allow the Thunderbird composer window to reside on any desktop and when activated, force focus and pop it to the top of all windows.

- Pop the Thunderbird reminder to the top and do not give it focus so it isn't inadvertently dismissed.

Each rule's matching criteria is sufficiently restrictive so their order within the main &kwin; window is not important to affect rule evaluation.

#### Thunderbird - Main

Assuming the Thunderbird Main window is open, sized and position to suit:

1. Use Detect Window Properties and select the Thunderbird Main window. Check the Window role box to restrict the criteria to the main window - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the following attributes:

4. Click through to complete entry of the rule.

#### Thunderbird - Composer

Assuming a Thunderbird Composer window is open:

1. Use Detect Window Properties and select the Thunderbird Compose window. Check the Window role and Window type boxes to restrict the criteria to composition windows - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the following attributes:

4. Click through to complete entry of the rule.

#### Thunderbird - Reminder

Assuming a Thunderbird Reminder window is open:

1. Use Detect Window Properties and select the Thunderbird Reminder window. Check the Secondary class name and Window Type boxes to restrict the criteria to reminder windows - for additional information see window matching:

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description box:

3. Enable the following attributes:

4. Click through to complete entry of the rule.

## Application Workarounds

Below are Workarounds for misbehaving applications.

If you are unfamiliar with creating &kwin; Rules, see this detailed example to base your new rule.

### Full-screen Re-size Error

&Emacs; and gVim, when maximized (full-screen mode) and under certain conditions may encounter window re-sizing issues - see Emacs window resizes ... A &kwin; Rule will work-around the issue.

Assuming an &Emacs; window is open:

1. Use Detect Window Properties and select the &Emacs; window. Match only by primary class name so leave the check boxes unchecked - for additional information see window matching

2. Clicking OK in the previous window back-fills the results in the Window Matching tab. Enter a meaningful text in the Description text box:

3. Ignore &Emacs;'s full-screen request by enabling the Obey geometry restrictions attribute, toggling it to off (No) to ignore and selecting the Force parameter:

4. Click through to complete entry of the rule.

## Credits and License

Documentation Copyright see the UserBase KWin Rules page history

&underFDL;
&documentation.index;