You are not logged in.

#1 2011-07-31 02:31:15

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

[Solved] Awesome WM hooks

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

#2 2011-07-31 05:01:52

Guff
Member
Registered: 2009-09-30
Posts: 158
Website

Re: [Solved] Awesome WM hooks

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

#3 2011-07-31 10:28:23

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [Solved] Awesome WM hooks

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

#4 2011-07-31 13:48:04

Guff
Member
Registered: 2009-09-30
Posts: 158
Website

Re: [Solved] Awesome WM hooks

What does your error log report?

Offline

#5 2011-07-31 14:27:06

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [Solved] Awesome WM hooks

Guff wrote:

What does your error log report?

/home/ian/.config/awesome/rc.lua:275: attempt to call method 'add_signal' (a nil value)

Offline

#6 2011-07-31 15:06:24

Guff
Member
Registered: 2009-09-30
Posts: 158
Website

Re: [Solved] Awesome WM hooks

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?

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

#7 2011-07-31 15:58:50

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [Solved] Awesome WM hooks

Guff wrote:
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

#8 2011-07-31 16:15:11

Guff
Member
Registered: 2009-09-30
Posts: 158
Website

Re: [Solved] Awesome WM hooks

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

#9 2011-07-31 16:44:05

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: [Solved] Awesome WM hooks

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

Board footer

Powered by FluxBB