OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
hyprland-config medium very-common DISPUTE

Fix a window rule that never fires because the class does not match

hyprlandomarchyarchendeavouroscachyosmanjarowayland
CORRECTED An auditor found the fix wrong or incomplete and rewrote it.
AUDIT NOTE

The diagnosis is excellent and fully verified: the current Window-Rules wiki confirms Hyprland uses Google RE2 ('all operations requiring polynomial time to compute will not work', so lookaheads/backreferences silently fail), confirms negative: as the negation prefix with negative:kitty as its own example, and confirms class/title/initial_class/initial_title/xwayland as match props. The hyprctl clients / activewindow / jq inspection commands are right, and the closing advice about Electron/Java apps changing class late maps exactly onto the wiki's static-vs-dynamic split. But the Lua example is broken and contradicts the record's own following sentence. "^(com%.obsproject%.Studio)$" uses %., which is Lua *pattern* escaping. The string is handed to RE2, where % is a literal percent, so that regex matches the literal text 'com%.obsproject%.Studio' and will never fire. A user copy-pastes it and reproduces the exact bug the record is about.

The cause above was not rewritten and may still contain the error described. The fix below is the corrected version.

Symptom

A window rule 'does nothing': windowrule = match:class ^(discord)$, workspace 4 never fires, the app still opens tiled on the current workspace, and there is no error in hyprctl configerrors.

Cause

The class string in the rule does not match what the window actually reports. Common causes: the real app_id is reverse-DNS (com.mitchellh.ghostty, org.gnome.Nautilus, com.obsproject.Studio) not the friendly name. XWayland reports a different, often capitalised class than the Wayland app_id. The regex is anchored with ^(...)$ but the real value has a suffix. Matching is case-sensitive. Hyprland uses Google RE2, so lookaheads/backreferences silently never match.

Fix

Everything except the Lua regex is correct. Replace the Lua example. RE2 does not understand Lua's % escapes:


-- WRONG: %. is a Lua pattern escape; RE2 reads % literally, so this never matches
-- hl.window_rule({ match = { class = "^(com%.obsproject%.Studio)$" }, workspace = "4" })

-- Right - escape for RE2, doubling the backslash for the Lua string literal:
hl.window_rule({ match = { class = "^(com\\.obsproject\\.Studio)$" }, workspace = "4" })

-- Or use a long-bracket string so no Lua-level escaping is needed at all:
hl.window_rule({ match = { class = [[^(com\.obsproject\.Studio)$]] }, workspace = "4" })

The record's own note ("escape the dot as \\. in a normal quoted string or use [[...]]") is the correct rule. The example just does not follow it.

Verify

Reopen the app. hyprctl clients shows it on the intended workspace/floating state. hyprctl -j clients | jq '.[].class' matches your regex exactly.

Sources

windowrule-not-matching-wrong-class