Active Window Widget Options#
Shows the title of the window you are currently using right in your status bar. You can format the text however you like, switch between different label styles, automatically hide titles for specific apps, rewrite text patterns using rules, and even display the app's icon.
| Option | Type | Default | Description |
|---|---|---|---|
label |
string | "{win[title]}" |
The label format for the active window. |
label_alt |
string | "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]" |
The alternative label format for the active window. |
class_name |
string | "" |
Additional CSS class name for the widget. |
label_no_window |
string | None |
The label to display when no window is active. |
label_icon |
boolean | true |
Whether to display an icon with the label. |
label_icon_size |
integer | 16 |
The size of the icon displayed with the label. |
max_length |
integer | None |
The maximum length of the label text. |
max_length_ellipsis |
string | "..." |
The ellipsis to use when the label text exceeds the maximum length. |
monitor_exclusive |
boolean | true |
Whether the widget should be exclusive to the monitor. |
ignore_window |
dict | {'classes': [], 'processes': [], 'titles': []} |
Windows to ignore based on class names, process names, and titles. |
callbacks |
dict | See below | Callbacks for mouse events on the widget. |
rewrite |
list | [] |
List of rewrite rules for the widget. See below |
keybindings |
list | [] |
Optional hotkeys. See Keybindings. |
Callbacks#
The callbacks option maps mouse buttons (on_left, on_middle, on_right) to actions. All keys are optional, the values shown are the defaults.
callbacks:
on_left: "toggle_label"
on_middle: "do_nothing"
on_right: "do_nothing"
Available actions:
toggle_label- Switch betweenlabelandlabel_alt.do_nothing- Do nothing.exec <command>- Run a command, for exampleexec cmd.exe /c start ms-settings:network.
Example Configuration#
active_window:
type: "yasb.active_window.ActiveWindowWidget"
options:
label: "{win[title]}"
label_alt: "[class_name='{win[class_name]}' exe='{win[process][name]}' hwnd={win[hwnd]}]"
label_no_window: ""
label_icon: true
label_icon_size: 16
max_length: 56
max_length_ellipsis: "..."
monitor_exclusive: true
Description of Options#
- label: The format string for the active window title. You can use placeholders to dynamically insert window information. See Label Format Placeholders below.
- label_alt: The alternative format string for the active window. Useful for displaying additional window details. Supports the same placeholders as
label. - class_name: Additional CSS class name for the widget. This allows for custom styling.
- label_no_window: The text to display when no window is active. If not specified, it defaults to an empty string.
- label_icon: A boolean indicating whether to display the window icon.
- label_icon_size: The size of the window icon in pixels.
- max_length: The maximum number of characters to display for the window title. Must be greater than 0. If the title exceeds this length, it will be truncated.
- max_length_ellipsis: The string to append to truncated window titles.
- monitor_exclusive: A boolean indicating whether the widget should be exclusive to a single monitor.
- ignore_window: A dictionary specifying which windows to ignore. It contains three lists: classes, processes, and titles.
- callbacks: Mouse event callbacks. See Callbacks.
- rewrite: A list of rewrite rules for the widget. Rewrite rules are applied to
title,process.name, andapp_name. See Rewrite Options below. - keybindings: A list of global hotkeys for this widget. See Keybindings.
Label Format Placeholders#
You can use the following placeholders in label and label_alt:
| Placeholder | Description | Example |
|---|---|---|
{win[title]} |
Window title | "Document1 - Microsoft Word" |
{win[app_name]} |
Friendly application name (resolved from process). | "Photos" |
{win[class_name]} |
Window class name | "Chrome_WidgetWin_1" |
{win[hwnd]} |
Window handle (HWND) | 1234567 |
{win[process][name]} |
Process executable name | "explorer.exe" |
{win[process][pid]} |
Process ID | 12345 |
{win[process][path]} |
Full path to the executable | "C:\Windows\explorer.exe" |
{win[monitor_hwnd]} |
Monitor handle | 65537 |
Label Examples#
# Show just the window title
label: "{win[title]}"
# Show friendly app name
label: "{win[app_name]}"
# Show app name followed by window title
label: "{win[app_name]} - {win[title]}"
# Show process name and title
label: "{win[process][name]}: {win[title]}"
# Show detailed info on alt label
label_alt: "[{win[app_name]}] class='{win[class_name]}' exe='{win[process][name]}' pid={win[process][pid]}"
Rewrite Options#
The rewrite option allows you to supply a list of search-and-replace rules to be applied, in order, to the window title. Each rule is a dict with the following schema:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
pattern |
string | yes | None | A Python regular expression to match against the raw window title. More Info |
replacement |
string | yes | None | The replacement text; can use backrefs like \1, \2, etc. |
case |
string | no | None | If specified, the replacement will be converted to the specified case. Allowed values: lower, upper, title, capitalize |
Example#
active_window:
type: "yasb.active_window.ActiveWindowWidget"
options:
label: "{win[title]}"
# ...
rewrite:
# Strip trailing “.exe” (case-insensitive) and lowercase:
- pattern: "^(.+?)\\.exe$"
replacement: "\\1"
case: lower
# Uppercase the literal word “Studio” anywhere in the title:
- pattern: "\\bStudio\\b"
replacement: "STUDIO"
# Replace any title like “...YASB Reborn - Foo” with “🌎 Foo”
- pattern: "(.*)YASB Reborn -(.*)$"
replacement: "🌎 \\2"
Example Style#
.active-window-widget {}
.active-window-widget.your_class {} /* If you are using class_name option */
.active-window-widget .widget-container {}
.active-window-widget .widget-container .label {}
.active-window-widget .widget-container .label.alt {}
.active-window-widget .widget-container .icon {}