The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
0

Why doesn't regex work the same in the i3 config?

asked 2014-01-12 07:27:02 +0000

paramnesioid gravatar image

updated 2014-01-12 07:32:08 +0000

I definitely can move only the windows with 'Private Browsing' in the title using a terminal to run this command:

i3-msg [title=".Private.Browsing."] move to workspace "Private Browsing"
and this works too:

i3-msg [title=".*\(Private.Browsing\).*"] move to workspace "Private Browsing"
In the i3 config, these commands work:
assign [class=".*Firefox.*"] "Firefox Window"
assign [title=".*Firefox.*"] "Firefox Window 2"
assign [title=".*Mozilla.*"] "Firefox Window 3"

these don't work (and they are identical to the ones above):

assign [title=".*Private.*"] "Firefox Window 4" 
assign [title=".*Private.Browsing.*"] "Firefox Window 5"
assign [title=".*\(Private Browsing\).*"] "Private Browsing"

This is what I got when I xpropped the normal and private windows:

WM_NAME(STRING) = "Mozilla Firefox Start Page - Mozilla Firefox"
WM_NAME(STRING) = "Private Browsing - Mozilla Firefox (Private Browsing)"

So, all of the commands work from a terminal, but only some work in i3. What's happening here?

edit retag flag offensive close merge delete

Comments

That was my question too, and it wasn't resolved then. However, this is specifically about regex not working (not necessarily about Firefox), considering that I've got examples of it working in terminal and it not working in the i3 config.

paramnesioid gravatar imageparamnesioid ( 2014-01-12 07:53:20 +0000 )edit

Okay, I was wrong.

paramnesioid gravatar imageparamnesioid ( 2014-01-13 11:30:35 +0000 )edit

3 answers

Sort by » oldest newest most voted
1

answered 2014-01-13 10:30:35 +0000

Adaephon gravatar image

updated 2014-01-13 10:44:32 +0000

The problem is not due to any difference in parsing the regex.

The issue in this case (and in your other question) is, that "Private Browsing" is not part of the title, when the window is created. Firefox adds this only after the window is initialized. If you watch closely, you can see, that the title of the new window is "Mozilla Firefox" at first.

assign is designed to only affect newly created windows, as such it can only use the attributes with which a window is created. When you use the criteria on the command line with i3-msg (or in any key binding in the config), the current attributes of a window are used.


I managed to get the new window with xprop before the title was reset. Here the relevant parts:

WM_CLASS(STRING) = "Navigator", "Firefox"
WM_NAME(STRING) = "Mozilla Firefox"

Unfortunatelly there seems to be no distinguishing attribute between normal and private windows on creation time.

edit flag offensive delete link more

Comments

Okay that makes sense. Thanks heaps!

paramnesioid gravatar imageparamnesioid ( 2014-01-13 11:29:21 +0000 )edit
2

answered 2014-01-13 12:15:05 +0000

TonyC gravatar image

Like Adaephon said, the window is changing its title after the window is created. The assign config command is only effective when the window is first initialized.

If you want to issue a command for a window that will execute whenever the window meets the criteria, you have to use for_window.

for_window [title=".*Private.*"] move to workspace "Firefox Window 4" 
for_window [title=".*Private.Browsing.*"] move to workspace "Firefox Window 5"
for_window [title=".*\(Private Browsing\).*"] move to workspace "Private Browsing"
edit flag offensive delete link more

Comments

Great solution to the underlying problem. Could you also (instead?) post it as answer to the [original question](https://faq.i3wm.org/question/2867/how-do-i-make-firefox-open-a-private-browsing-window-on-another-workspace)? It would fit better there.

Adaephon gravatar imageAdaephon ( 2014-01-13 12:37:00 +0000 )edit

Okay that works well. Thanks, TonyC!

paramnesioid gravatar imageparamnesioid ( 2014-01-13 12:53:28 +0000 )edit

np. I think this should be closed as a duplicate since it turns out not to be a regexp problem.

TonyC gravatar imageTonyC ( 2014-01-13 16:27:52 +0000 )edit
0

answered 2014-01-12 09:26:34 +0000

Michael gravatar image

This answer doesn’t specifically address why the regexp does not work, but tells you how to debug it:

See http://i3wm.org/docs/debugging.html on how to get to the log file. In there, you’ll see messages like this:

2014-01-12 10:25:11 - assignments.c:run_assignments:20 - Checking if any assignments match this window
2014-01-12 10:25:11 - Checking window 0x00e008c9 (class URxvt)
2014-01-12 10:25:11 - Regular expression "^mcabber$" does not match "urxvt"

So there you have the regular expression as i3 parsed it plus the specific string that it is trying to match against. The matching is done using libpcre, so check the PCRE manual for details on the syntax etc.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-12 07:27:02 +0000

Seen: 657 times

Last updated: Jan 13 '14