The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Focus on a window of a certain class *unless* it has a certain title

asked 2013-06-23 04:54:27 +0000

mk gravatar image

updated 2013-06-24 00:30:21 +0000

As explained in the i3 documentation, to focus on a window of class, say, "Emacs", it is enough to write:

bindsym $mod+x [class="Emacs"] focus

However, I'd like to focus on a Emacs window unless the Emacs window has a certain title, say, "emacs_scratchpad". I'm not sure how to implement the unless bit. Does anyone know?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-06-23 08:04:49 +0000

updated 2013-06-24 06:29:47 +0000

You can try the criteria for "title" and Negative Lookahead assertion, which is PCRE (Perl Compatible Regular Expression) compliant:

bindsym $mod+x [class="Emacs" title="^(?!emacs_scratchpad)"] focus

Haven't tried, but should work.

References:

[1] [http://www.regular-expressions.info/l...

[2] [http://i3wm.org/docs/userguide.html#listofcommands](http://i3wm.org/docs/userguide.html#listofcommands)

edit flag offensive delete link more

Comments

?! alone didn't work out for me. I had to add "^" before---i.e., "^(?!emacs_scratchpad)." Thanks a bunch!

mk gravatar imagemk ( 2013-06-24 00:08:18 +0000 )edit

ok, makes sense. (will edit the answer for future reference, and it answers your question, mark it as answered, or it will keep popping up in the main page).

bruno.braga gravatar imagebruno.braga ( 2013-06-24 06:29:23 +0000 )edit

wow, this is one of those things which make i3 great! I've yet to find another window manager which allows for doing this in such a concise and clean way. Brilliant!

ack006 gravatar imageack006 ( 2013-07-10 16:08:20 +0000 )edit

Question Tools

Stats

Asked: 2013-06-23 04:54:27 +0000

Seen: 291 times

Last updated: Jun 24 '13