You are not logged in.
Does anyone know of any good documentation available for awesome's hook mechanisms? The awesome wiki says (for many things, not just hooks) to look at the man page, but awesome's man pages are not very informative for anything other than the default keybindings.
What I want to do is have awesome automatically execute a function when I switch to certain tags. I'm assuming this requires a hook, but I have no idea what the necessary variables/objects are.
Thanks
Last edited by ibrunton (2011-07-31 16:44:51)
Offline
Have you seen this? I think that's what you're looking for.
The signal you'd be interested in connecting to would be property::selected of a given tag object.
Something like
tags[1].add_signal("property::selected", function (tag) <do stuff> end)
...I think.
Offline
Hmm, nope. In fact, it breaks something (running "awesome -k" to check the config file reports no errors, but reloading awesome reverts to the default theme and layout).
Offline
Offline
What does your error log report?
/home/ian/.config/awesome/rc.lua:275: attempt to call method 'add_signal' (a nil value)
Offline
/home/ian/.config/awesome/rc.lua:275: attempt to call method 'add_signal' (a nil value)
Are you using awesome or awesome-git?
Because I think the method is "connect_signal" in awesome-git.
Edit: Also, oh whoops, it should have been
tags[1]:add_signal
not
tags[1].add_signal
Dunno if you caught that or not.
Last edited by Guff (2011-07-31 15:10:07)
Offline
ibrunton wrote:/home/ian/.config/awesome/rc.lua:275: attempt to call method 'add_signal' (a nil value)
Are you using awesome or awesome-git?
Just awesome.
Edit: Also, oh whoops, it should have been
tags[1]:add_signal
not
tags[1].add_signal
Dunno if you caught that or not.
I actually tried it both ways. With a . the error is "attempt to call field 'add_signal' (a nil value)" and with a : the error is "attempt to call method 'add_signal' (a nil value)". For the record, I also tried it as "tags:add_signal" instead of "tags[1]:add_signal" but it makes no difference.
Offline
Ah. I forgot at first that tags is a table of tables of tags, rather than just a table of tags. So, you need to do
tags[s][1]:add_signal
where s is the screen. Might want to put that in a loop that iterates over all your screens.
Offline
Yes, I discovered that just now myself, and it works.
There seems to be just one tiny issue, which causes the function to be called both when switching to tags[1][1] and when switching from. I'm not sure whether it's a bug or designed behaviour. It's not what I intended, but I don't think it'll be a problem for me.
FWIW, the function I'm calling simply moves the mouse cursor out of the way when switching to a tiled tag. I got it from this page on the Awesome Wiki. For all I know, I might decide I want this function called for every tag so I always know where the cursor is. We'll see.
Thanks for your help, Guff!
Offline