PDA

View Full Version : Window Matching Guide Support Thread


Jupiter
May 31st, 2007, 08:15 PM
The guide can now be found on the Compiz Fusion wiki at http://wiki.compiz-fusion.org/WindowMatching.

Deciare
August 14th, 2007, 04:35 AM
Let's demonstrate some of the information covered above with a tutorial.
I want the Amarok window to appear on all desktops, always on top, and at 25% opacity every time I start it. How can I do that?

General Options and two plugins, Window Rules and Regex Matching, will be involved in this tutorial. Please ensure that they're all enabled before continuing further.


Identifying a Window

First, you'll need a way to identifying the Amarok window. To do this, open a console window, enter the command xprop then click on the Amarok window. You'll see lots of lines appear in the console, including these:
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING
WM_NAME(STRING) = "Amarok"
WM_LOCALE_NAME(STRING) = "en_CA.UTF-8"
WM_CLASS(STRING) = "amarokapp", "Amarokapp"

Here, we see 4 different ways to identify the Amarok window. I've colour coded them to make this example easier to follow:
type=normal - This will match any window of the type Normal, so it won't help a lot in this case!
title=^Amarok$ - This will match any window whose title is exactly "Amarok"--with nothing before it, and nothing after it. You can use "^Amarok" to match all windows whose titles begin with Amarok, and "Amarok$" to match all windows whose titles end with Amarok. (You can use other regular expressions, too. But explaining what a regular expression is, is well outside the scope of this guide.)
name=amarokapp - This will match the first string quoted next to WM_CLASS(STRING).
class=Amarokapp - This will match the second string quoted next to WM_CLASS(STRING).

There is no best way to match a window. Exactly which way is best depends on the window you're trying to match. In this case, let's use a combination of two methods: "name=amarokapp & type=normal" to identify the Amarok window. The & between the two criteria means match both the name and the type criteria.

Now that we know how to identify our window, we need to give it some rules.


Opacity

Let's begin with translucency. Under ccsm->General Options, you'll see one list called Opacity window values, and another list called Opacity windows. The first line in the Opacity window values list will define the opacity for the windows matched by the first line in the Opacity windows list, and so on.

For this example, we'll assume that both lists are blank.

In the Opacity window values list, add a line that says "75". That means 75% opaque, or 25% translucent.

In the Opacity windows list, add a line that says "name=amarokapp & type=normal". (Remember that line from the previous section?)


Window Attributes

To make a window open with certain attributes, such as showing up on all desktops and begin always on top, we can use the Window Rules plugin. Find it at ccsm->Window Rules.

Here, you'll see a list of attributes that can apply to different windows. To make a window show up on all desktops, it needs to be Sticky. To make a window always on top, it needs to be Above.

So we'll enter our window's identity, "name=amarokapp & type=normal", input both the Sticky and Above fields.



... And that's it! Wasn't that simple? :mrgreen: Probably not, but ccsm is a work in progress. It will get easier over time, both because you get used to it and because CompComm's developers will continue to improve it!

maniac
August 14th, 2007, 09:46 AM
Widget - (Deciare: I have no idea. Suggestions?)

The _COMPIZ_WIDGET X property is set for windows matching this match. This property is picked up by the widget plugin to place those windows on a separate layer. Guess we need to decide whether this match better suits into winrules or widget, because currently widget has such a match, too ;)

luckycatfu
August 26th, 2007, 05:23 AM
Is it possible to use window rules to tell some windows to open maximised while others do not? (Maximised, not fullscreen - I want to be able to see my dock and titlebar)

derkosak
September 5th, 2007, 09:51 PM
Hi there
is there any way to avoid needing to change the window decorator from and to compiz to run Java windows like Netbeans (azureus works fine) by using window matching rules?
Or, is there any other way?
thanks!

phaedOne
September 8th, 2007, 06:30 AM
Heres a quick script i wrote up that ive been using. Posting it here in case someone might find it useful.

#!/bin/sh

case "$1" in
-type ) xprop | grep WINDOW_TYPE | cut -d _ -f 10 ;;
-role ) xprop | grep "WM_WINDOW_ROLE(STRING)" | cut -d \" -f 2 ;;
-name ) xprop | grep WM_CLASS | cut -d \" -f 2 ;;
-class ) xprop | grep WM_CLASS | cut -d \" -f 4 ;;
-title ) xprop | grep "WM_NAME(STRING)" | cut -d \" -f 2 ;;
-xid ) xprop | grep "WM_CLIENT_LEADER(WINDOW)" | cut -d ' ' -f 5 ;;
-all )
xprop > tmp
echo -n "type: "; grep WINDOW_TYPE tmp | cut -d _ -f 10
echo -n "name: "; grep WM_CLASS tmp | cut -d \" -f 2
echo -n "class: "; grep WM_CLASS tmp | cut -d \" -f 4
echo -n "title: "; grep "WM_NAME(STRING)" tmp | cut -d \" -f 2
echo -n "xid: "; grep "WM_CLIENT_LEADER(WINDOW)" tmp | cut -d ' ' -f 5
rm tmp
;;
* ) echo "Usage: xp -[type|role|name|class|title|xid|all]" >&2; exit 1;;
esac


*name the script "xp". then chmod +x xp

Usage:

$ xp -type #click on the desktop
DESKTOP

$ xp -all #click on the desktop
type: DESKTOP
name: desktop_window
class: Nautilus
title: Desktop
xid: 0x1000001

GypsyMuffin
September 17th, 2007, 04:36 PM
Hi,

Is there a way to have the Window Rules recognize specific hotkeys for certain windows? I use this extensively with kwin (e.g., Ctrl+Alt+Shift+F = Firefox, C+A+S+E = Emacs, C+A+S+B = Gaim/Pidgin, and many others.)

This is the last feature that prevents me from leaving kwin and moving to compiz full time. It seems that Window Rules would have the infrastructure to add this feature without too much difficulty, if it doesn't allow arbitrary hotkey/window mapping now.

Thanks!

Jupiter
September 17th, 2007, 08:38 PM
Hi,

Is there a way to have the Window Rules recognize specific hotkeys for certain windows? I use this extensively with kwin (e.g., Ctrl+Alt+Shift+F = Firefox, C+A+S+E = Emacs, C+A+S+B = Gaim/Pidgin, and many others.)

This is the last feature that prevents me from leaving kwin and moving to compiz full time. It seems that Window Rules would have the infrastructure to add this feature without too much difficulty, if it doesn't allow arbitrary hotkey/window mapping now.

Thanks!
That can be done using ccsm --> general options --> commands =
Then define the keybinding for said command in ccsm --> general options --> key bindings =
The command line # should correspond to the key binding #

Jupiter
September 17th, 2007, 08:41 PM
Is it possible to use window rules to tell some windows to open maximised while others do not? (Maximised, not fullscreen - I want to be able to see my dock and titlebar)
Yes you can use ccsm --> windows rules --> fixed sized windows =
to define a windows size when opened.

GypsyMuffin
September 17th, 2007, 08:57 PM
That can be done using ccsm --> general options --> commands =
Then define the keybinding for said command in ccsm --> general options --> key bindings =
The command line # should correspond to the key binding #

Jupiter, thanks for your reply. I took a look at this, and it seems to only be able to run system commands. I'm looking for a way to define shortcuts to activate already open windows, even if the window is minimized on another desktop or another side of the cube. (as kwin does now in the case of multiple desktops.)

badabing
September 21st, 2007, 02:10 PM
im trying to get a transparent text editor on my desktop, so that i can type directly on the desktop and keep notes and reminders for example
but i havent been able to make it work the way i want to, i can get the editor transparent but then the text ive written becomes transparent too..

any idea how to get this working ?
tomboy and the notes screenlet doesent do it for me, nor the sticky notes thing

SpmP
October 12th, 2007, 02:46 AM
Is it possible to force a window onto a specific viewport.
And give it initial position.

Thank you.

Deciare
October 19th, 2007, 02:27 AM
Is it possible to force a window onto a specific viewport.
And give it initial position.

Thank you.
Yes. In ccsm->Place Windows->Fixed Window Placement, you can define a list of windows that always show up at the same location on a desktop, as well as a list of windows that always show up on a certain viewport.

The first list, Windows with fixed positions, lets you tell a window where to appear on a desktop. X represents its horizontal position, with 0 meaning the far left, and Y represents its vertical position, with 0 meaning the top.

The second list, Windows with fixed viewport, works the same way, but with viewport coordinates instead of pixel coordinates.

You can create window matching rules the same way as described on the first page of this thread.

This only works for windows that don't set their own initial positions, though. An Amarok window, for example, will open where you last closed it no matter what rule you set for Windows with fixed positions.

Deciare
October 19th, 2007, 02:32 AM
im trying to get a transparent text editor on my desktop, so that i can type directly on the desktop and keep notes and reminders for example
but i havent been able to make it work the way i want to, i can get the editor transparent but then the text ive written becomes transparent too..

any idea how to get this working ?
tomboy and the notes screenlet doesent do it for me, nor the sticky notes thing
At this point, it's not possible to make the background of a window transparent without also making the foreground (text) transparent... To do what you describe, you would need a compositing-aware editor that can set its own transparency, instead of relying on the winrules plugin. I don't know of any such editor, sorry...

andqso
October 22nd, 2007, 05:14 AM
im trying to get a transparent text editor on my desktop, so that i can type directly on the desktop and keep notes and reminders for example
but i havent been able to make it work the way i want to, i can get the editor transparent but then the text ive written becomes transparent too..

any idea how to get this working ?
tomboy and the notes screenlet doesent do it for me, nor the sticky notes thing

Consider setting up a gnome-terminal with a transparent background on the desktop and opening it to your editor of choice.

Deciare
October 22nd, 2007, 06:00 AM
Ooh, yes, that'll work! :D Refer to this guide (http://ubuntu-unleashed.blogspot.com/2007/08/howto-completely-transparent-shell-on.html) for pretty good instructions on getting an always-on-desktop terminal session going. Just be aware that all the window matching rules that say "title=trans" should be "title=^trans$" instead, or it will match any window with the word "trans" in any part of its title.

maebemae
October 23rd, 2007, 11:07 PM
trying to get my Pidgin Buddy List to show up only on the widget layer.

here's what my xprop spit out about it:

_NET_FRAME_EXTENTS(CARDINAL) = 10, 10, 30, 10
_NET_FRAME_WINDOW(WINDOW): window id # 0x12001b4
WM_WINDOW_ROLE(STRING) = "buddy_list"
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_MOVE, _NET_WM_ACTION_RESIZE, _NET_WM_ACTION_STICK, _NET_WM_ACTION_MINIMIZE, _NET_WM_ACTION_MAXIMIZE_HORZ, _NET_WM_ACTION_MAXIMIZE_VERT, _NET_WM_ACTION_FULLSCREEN, _NET_WM_ACTION_CLOSE, _NET_WM_ACTION_SHADE, _NET_WM_ACTION_CHANGE_DESKTOP, _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35651684
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2200063
WM_CLIENT_LEADER(WINDOW): window id # 0x2200001
_NET_WM_PID(CARDINAL) = 5834
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "Macbuntu"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
program specified location: 0, 0
window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "pidgin", "Pidgin"
WM_ICON_NAME(STRING) = "Buddy List"
_NET_WM_ICON_NAME(UTF8_STRING) = 0x42, 0x75, 0x64, 0x64, 0x79, 0x20, 0x4c, 0x69, 0x73, 0x74
WM_NAME(STRING) = "Buddy List"
_NET_WM_NAME(UTF8_STRING) = 0x42, 0x75, 0x64, 0x64, 0x79, 0x20, 0x4c, 0x69, 0x73, 0x74


Under the Window Rules > Widget I put

title=^Buddy List$

this doesn't seem to have any effect. not sure where to go from here.

side note: also tried to set my Buddy List's opacity to 75% and that's no worky either.

thanks.

Deciare
October 24th, 2007, 12:11 AM
title=^Buddy List$ works for me. Are you sure the Regex Matching plugin is enabled?

maebemae
October 24th, 2007, 03:07 AM
title=^Buddy List$ works for me. Are you sure the Regex Matching plugin is enabled?
yup.

i just tried it again and it didn't work. when i invoke the widget layer it's not there. i just copy/pasted from your code box into the "Widget" in Window Rules.

I'm wondering if I've got something going on with my Widget Layer, though. I just installed screenlets and I've had them working before (pre-gutsy) and they don't do anything now. i can't get any to launch.

Deciare
October 24th, 2007, 04:09 AM
Hmm. Are we putting this rule in the same place? I'm putting it into ccsm->Widget Layer->Behaviour->Widget Windows. As soon as I pasted the rule and pressed Enter, the Buddy List window vanished from the non-widget view.

There's a Widget field in the Window Rules plugin that presumably does the same thing, but maybe it's not working quite so well?

maebemae
October 24th, 2007, 09:32 PM
that worked! i was putting it into the Window Rules -> Widget spot. that did nothing for me. when i put it in the Widget Layer Windows box it worked. Thanks!

New question. Because i have opacify enabled, when I go to my widget alayer, my widgets are transparent unless i'm hovering over them. how do i tell Opacify not to work for the widget layer?

thanks for your help!

Deciare
October 25th, 2007, 01:12 AM
My version of Opacify doesn't affect the widget layer by default, so I'm not sure exactly what you mean, but it may help if you include !widget=1 as a condition somewhere in your ccsm->Opacify->Misc. Options->Window Match rule.

In the case of my default rule, I would rewrite it like:
(Normal | Dialog | ModalDialog | Utility | Toolbar | Fullscreen) & !widget=1

maebemae
October 25th, 2007, 02:22 AM
worked!

thank you very much for your help in multiple threads!

Scob
November 21st, 2007, 04:38 AM
Hey!

Is it possible to make a predefined window to start sticky in a viewport?!

thanks

dpetka2001
January 27th, 2008, 08:17 PM
i'm trying to create a rule to open new firefox windows with a fixed size 800x600 using the following rule "title=Firefox$ & !override_redirect=1" and then define the height to 800 and the width to 600...but still it opens in the resolution of my monitor that's 1280x1024...am i doing something wrong??

crdlb
January 27th, 2008, 09:05 PM
i'm trying to create a rule to open new firefox windows with a fixed size 800x600 using the following rule "title=Firefox$ & !override_redirect=1" and then define the height to 800 and the width to 600...but still it opens in the resolution of my monitor that's 1280x1024...am i doing something wrong??

Try the rule iclass=firefox & type=normal & !(state=maxvert | state=maxhorz)

If you close a firefox window maximized, then it won't work (I added that bit to the end of the rule so that it wouldn't affect maximized windows). Without that part, it'll cause buggy behavior when firefox wants to be maximized. The only way I can think of to guarantee that it would work would be to add the first part of that rule to the non-maximizable windows field.

crdlb
January 27th, 2008, 09:24 PM
Is it possible to make a predefined window to start sticky in a viewport?!
thanks

Just create a rule to match that window, and put it in:
1) the Sticky field in Window Rules, and
2) the Windows with fixed viewport field in Place Windows (putting, for example, 3 and 0 for X and Y Viewport Positions, respectively, if you wanted to put it on the fourth horizontal viewport and first vertical viewport.)