PDA

View Full Version : Match window name with regex (devilspie)



demontager
April 9th, 2017, 11:40 AM
I'm searching a way to match window name title in order to close it automatically upon popping-up. This should work in devilspie, but i didn't find a way to match window by regex.
For instance i have the window titles with such names

"Message from firstid@aol.im"
"Message from secondid@aol.im"
"Message from thirdid@aol.im"

And i need close them all by matching string "Message from"
I tried such construction generated by gdevilspie



; generated_rule pidgin_close
( if
( begin
( is ( window_name ) "Message from" )
)
( begin
( close )
( println "match" )
)
)


It obviously does not work, tried to put Message from* to be like regex, but also not.

Also tried devilpie2 with such regex suggested here https://github.com/gusnan/devilspie2/issues/8



if (string.find(get_window_name(),"Message from")~=nil) then
debug_print("found");
close();
end

nilandj-nilandsplace
April 29th, 2017, 03:25 PM
Hello Hope this helps someone!

I have found via trial and error to stay away from
( window_name ) As an example I have my Google Chrome start with my Gmail page so the window name actually comes out to be "Inbox - Myemail@gmail.com - Gmail". So if the Name changes I loose control over the Object. I get better control using
( window_class ) as the Class does not change. Also unless you have a use for it such as Sub Identifiers use only one Identifier as Devilspie seems to be easily confused by more Identifiers.
Here is the thing using a programmatically way to find the window ID does not always result in the ID that Devilspie will use. For example the Help Wiki suggest 2 ways with the terminal CLI,
xlsclients -l or
xwininfo, both will give a result that did not work for me. The former gave me
Instance/Class: google-chrome-stable/Google-chrome-stable and after 2 days trying it turns out to be "Google-chrome" and Devilspie is case sensitive. So what worked was
( is ( window_class ) "Google-chrome" ) The Od thing is on another Box running the same Ubuntu-Gnome version it works as
( is ( window_class ) "google-chrome" ) , so only the first capital is lower case? Go figure...!
Remember while Gdevilspie is an easier way to go it is only the GUI not the actual program that is running. Be sure to Stop and Start between each test for the changes to take effect via the GUI or kill devilspie and restart via the CLI, otherwise you may miss the 'One' that works.

James Niland