vlevit / xatk

a keyboard-driven window switcher for x11
GNU General Public License v2.0
14 stars 0 forks source link

Block some app from key assign #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to use 'n' for nautilus, but app with class 
desktop_window.Nautilus catch it. I set up in RULES section 

...
# don't bind windows that don't have class property
class.desktop_window = 
...

or 

title..*x-nautilus-desktop.* = zz

But it didn't work, in previous version last option work good.

My RULES section

---
class.desktop_window = 
class.chromium-browser = !c
class.gvim = !v
class.nautilus = !n
class.gnome-terminal = !t
class.pidgin = !p
class.skype = !s

---

Output of wmctrl -xl 

---
0x02800001  0 N/A                              N/A    /c/   /o/
0x02800002  0 N/A                              N/A launcher   /cv/   /oi/
0x02800003  0 N/A                              N/A panel   /cb/   /ou/
0x01200029  0 desktop_window.Nautilus  proft-notebook x-nautilus-desktop   /n/
0x03c00026  0 gnome-terminal.Gnome-terminal  proft-notebook Terminal   /t/
0x04200044  0 chromium-browser.Chromium-browser  proft-notebook New Issue - 
xatk - an efficient way of switching between windows for X - Google Project 
Hosting - Chromium   /c/
0x0120025e  0 nautilus.Nautilus     proft-notebook m   /nb/
0x04600024  0 gvim.Gvim             proft-notebook .xatkrc (~) - GVIM   /v/
0x04800006  0 goldendict.Goldendict  proft-notebook GoldenDict   /g/

---

Original issue reported on code.google.com by prof...@gmail.com on 10 Sep 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Some additional information: Ubuntu 11.04, GNOME 2.32.1

Original comment by prof...@gmail.com on 10 Sep 2011 at 6:57

GoogleCodeExporter commented 9 years ago
The reason why with
  class.desktop_window =
it doesn't work is that xatk uses only the second part of window class (the 
string after period). So this rule never applies to any window.

Having
  title.x-nautilus-desktop =
it will not work as you expect too. Say, you have the following windows:

1. title: x-nautilus-desktop, class: nautilus
2. title: abc, class: nautilus

and you have the following rules:

1. class.nautilus = !n
2. title.x-nautilus-desktop =

You want to apply the 2nd rule for window #1, and to apply the 1st
rule for window #2. xatk cannot know which rule to which window you
want to apply. So, it chooses rule #1 for both windows, because rules
with permanent keys have higher priority than others.

Improvements to xatk which could resolve this situation include:
1. Introduce a new property (e.g. class0) to rules, which would
correspond to the first part of the window class. Then, the rules
would look like:
  class0.desktop_window = 
  class0.nautilus = !n
2. Add support for something like logical AND for rules, e.g.
  class.nautilus AND title.x-nautilus-desktop = 
  class.nautilus AND title.(?!x-nautilus-desktop) = !n

While the first solution is simpler, I think the second one is more
common use case.

As a temporary workaround you can remove the following rule
  class.nautilus = !n
leave
  title.x-nautilus-desktop =
and add a history item
  nautilus = n
But of course, it will not guarantee that 'n' for nautilus will never
move to other window.

Feel free to make other suggestions or ask questions.

Original comment by levit.slava on 10 Sep 2011 at 8:47

GoogleCodeExporter commented 9 years ago
> it doesn't work is that xatk uses only the second part of window class (the 
string after period). So this rule never applies to any window.

If use full name of class (with period) or concatenate two parts in one.

If it isn't possible, I think that second variant (with logical operator) woul 
be cool.

> As a temporary workaround you can remove the following rule ... and add a 
history item.

Thanks! Ill use it.

> But of course, it will not guarantee that 'n' for nautilus will never move to 
other window.

I use small bash script with sed command witch change key for history items in 
~/.xatkrc, it work well for me :)

Original comment by prof...@gmail.com on 11 Sep 2011 at 9:06

GoogleCodeExporter commented 9 years ago
I think I've found a better way of handling such windows as x-nautilus-desktop. 
I have just discovered that x-nautilus-desktop is a window which is responsible 
for things like drawing icons on the desktop. So, its type is DESKTOP [1]. We 
can bind only windows which have type either NORMAL, or DIALOG by default. 
Therefore, desktop, panels, docks, splash screens will be ignored.

I think concatenating parts of WM_CLASS with period is not good. Mainly because 
the property itself can contain a period and secondly this would break already 
existing user-defined rules.

Using logical operator with syntax, I have suggested, is impossible because 
there is no way to determine if it is a part of previous regex or another 
expression. As for now, I think, implementation of logical expressions in rules 
would be a unreasonable complication and has a small set of use cases.

Your solution with use of sed sounds interesting :) But there is no guarantee 
anyway.

[1] Information about all window types can be found here: 
http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2551529

Original comment by levit.slava on 12 Sep 2011 at 5:47

GoogleCodeExporter commented 9 years ago
Great news! I am waiting with impatience for new version and ready for testing 
:)

Original comment by prof...@gmail.com on 14 Sep 2011 at 8:41

GoogleCodeExporter commented 9 years ago
Revision bb218db463a6 introduced window_types option, which is "NORMAL DIALOG 
UTILITY MENU" by default. So, now x-nautilus-desktop (DESKTOP) and some other 
windows should be ignored by default.

Original comment by levit.slava on 18 Sep 2011 at 1:30

GoogleCodeExporter commented 9 years ago
Excellent, i am really satisfied to use it.
I wrote a small review 
http://proft.me/2011/09/18/xatk-udobnoe-pereklyuchenie-okon/. 

Original comment by prof...@gmail.com on 18 Sep 2011 at 9:08

GoogleCodeExporter commented 9 years ago
Thanks for spreading the word.

Revision 0080ff5480 also provides a property called instance, which is the 
first part of WM_CLASS.

Original comment by levit.slava on 19 Sep 2011 at 6:24

GoogleCodeExporter commented 9 years ago
I saw it property, but i don't know where to use it now :) problem with 
nautilus is fixed and other apps work well with new version (y).

Original comment by prof...@gmail.com on 19 Sep 2011 at 8:02