Open tonobo opened 8 years ago
Uhm... What have you tried already that didn't work? This is just supposed to work (however, Lua's matches aren't really regexes):
{ rule = { name = ".*e.*" }, callback = function(c) print("There is an 'e' in here:", c) end }
Internally this uses string.match
, see e.g. http://lua-users.org/wiki/PatternsTutorial
There are some websites which are requires popups and i want to match against the windowtitle from chromium. But i am to noob i don't get it to work. Does it work for your? I tried it for OTRS 5 ticket open context.
I don't think I am matching against window title anywhere.
How about you add a rule like e.g. {rule = {}, callback = function(c) naughty.notify{ title="new window", text = c.name } end },
and use this to tell us what exactly is the window title that you want to match against?
There are some websites which are requires popups and i want to match against the windowtitle from chromium.
i guess the real problem here is what browser windows all initially have the same (blank) name, it got changed after name being processed by rules (while the page loads)
to workaround that i suggest you to setup a rule for your browser class in callback of which you could subscribe to signal when client name changes and only there match its name against your expression
I have the same question, so I'll chip in ; I try
local matcher = function(c) return awful.rules.match(c, {name = ".*Youtube.*"} ) end
awful.client.run_or_raise('google-chrome-stable --new-window https://www.youtube.com/', matcher)
in a key binding, and it runs a new window, rather than raise the existing one, even though there is a window that has :
~$ xprop WM_NAME WM_CLASS
WM_NAME(UTF8_STRING) = "The Awesome Window Manager - YouTube - Google Chrome"
WM_CLASS(STRING) = "google-chrome", "Google-chrome"
And, same as @actionless, I'm really trying to match browser windows with specific loaded pages, but they take a little while to load and set their WM_NAME
correctly. I worked around it, but if some clean code to handle that was available, that'd be great. This SO question is related.
@nikanar
It should be YouTube
, not Youtube
..
See http://lua-users.org/wiki/PatternsTutorial.
% lua
> tostring("The Awesome Window Manager - YouTube - Google Chrome"):match('YouTube')
YouTube
> tostring("The Awesome Window Manager - YouTube - Google Chrome"):match('.*YouTube.*')
The Awesome Window Manager - YouTube - Google Chrome
And for OP (@dopykuh): I think that it should work, but depending on your browser @actionless might be right.
So this means this can be closed?
Yes. https://github.com/awesomeWM/awesome/issues/977#issuecomment-230361080 might apply though.
btw, that's so annoying what this problem is not only prevents from creating rules for specific browser's windows, but also reproduces in some (if not most) chromium-based apps, like spotify
@actionless We could have some helper, like you described?!
yup, i want to make one in order to resolve my problem with spotify
It is a very bad idea to enable rules when a property change. You already can, but it will have nasty side effects such as flickers and "break" the text in dumb terminal such as xterm.
There is no way this will be enabled by default, ever. So what exactly do you want here? I think the issue should remain closed. The API exist.
I was thinking of a special rule field to simplify applying rule for a delayed property
For example, rule {class='firefox', delayed_name='pinterest'} On Sun, 29 Jan 2017 at 21:29, Emmanuel Lepage Vallée < notifications@github.com> wrote:
It is a very bad idea to enable rules when a property change. You already can, but it will have nasty side effects such as flickers and "break" the text in dumb terminal such as xterm.
There is no way this will be enabled by default, ever. So what exactly do you want here? I think the issue should remain closed. The API exist.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/awesomeWM/awesome/issues/977#issuecomment-275943483, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlDdbHyy0PveWBsEVdytfDNdXn9pXQgks5rXPawgaJpZM4I9NbG .
It wont help if the delayed property isn't the name. Why isn't the current syntax good enough?
local f
f = function(c)
if c.name == "SDFSDFSDFS" then
awful.rules.apply(c)
c:disconnect_signal("property::name", f) end
end
end
c:connect_signal("property::name", f)
Many thanks @blueyed, that works now, and thanks @Elv13 for sharing that snippet for us lua newbs around, it's a lot better than my workaround :)
Sorry, but I don't like the idea of a delayed_name
rule. For how long should the code wait for a name change? Is no rule applied until then? What if it never comes? Or is only the rule containing this delayed
thing delayed until then?
the idea is to replace smth like this:
-- All clients will match this rule.
{ rule = { },
properties = {
<.....>
},
callback = function(c)
awful.client.setslave(c)
if not c.class and not c.name then
local f
f = function(_c)
_c:disconnect_signal("property::name", f)
if _c.name == "Spotify" then
awful.rules.apply(_c)
end
end
c:connect_signal("property::name", f)
end
end
},
{ rule = { name = "Spotify" },
properties = {
tag=capi.screen.primary.tags[7],
raise=false
}
},
to smth like this:
-- All clients will match this rule.
{ rule = { },
properties = {
<.....>
},
callback = function(c)
awful.client.setslave(c)
end
},
{ rule = { delayed_name = "Spotify" },
properties = {
tag=capi.screen.primary.tags[7],
raise=false
}
},
if not c.class and not c.name then
Anything which passes not c.class
is not ICCCM-compliant (WM_CLASS
must be set before the window is mapped and is not allowed to change while the window is mapped) and not c.name
does not seem all that useful either (Sigh, Wayland will be so much better...). This might match Spotify, but I doubt that this would be useful in general. Sorry.
if that's some spotify-specific (however i doubt, i think it's at least for all chromium-based apps) then we should put it at least to the Receipts section
btw in spotify it got fixed now: https://www.reddit.com/r/awesomewm/comments/8hegiw/spotify_rule_is_now_possible/
is this not what the environment variable DESKTOP_STARTUP_ID should be used for ?
@ecocode Not everything supports SN. If you have a SN-supporting program, awful.spawn
directly accepts properties to apply to the resulting program. @Elv13 spend lots of time to make this easy to use. The problem stems from way too many things not supporting SN (or not supporting it properly).
Is there any possibilty to setup rules with a regex to match againgst a window name?