On 17.02.2012 10:03, Daniel wrote:
>>> I would like to have a function for viewing the next and previous non-empty
>>> tag (modulo sticky clients I suppose, but I don't really have any of those).
>>> I tried to break out and modify the viewnext/viewidx functions from
>>> awful.tag, but I messed up. Hacking rc.lua usually goes well, but the capi
>>> is a bit tougher. May I ask for some help? Wouldn't be surprised if this is
>>> already done somewhere.
>>
>> Dunno if this works, I've written this right now and never tested it:
>>
>> function view_non_empty(step, s)
>>    local s = s or 1
>>    -- The following makes sure we don't go into an endless loop
>>    -- if no clients are visible. I guess that case could be handled better,
>>    -- but meh
>>    local num_tags = #screen[s]:tags()
>>    for i=1, num_tags do
>>      awful.tag.viewidx(step, s)
>>      if #awful.tag.visible(s) == 0 then
>>        return
>>      end
>>    end
>> end
> 
> Thanks a lot, but I can't quite get it to work; can't seem to get a correct
> screen "s" passed into viewidx(). That function just complains "tag.lua:347:
> attempt to index local 'screen' (a number value)". Have tried passing it
> nothing and mouse.screen ...

Urgh. I love inconsistencies. :-(

Everything takes a screen number, but viewidx() wants a screen object.

New try:

function view_non_empty(step, s)
   local s = s or 1
   local scr = screen[s]
   -- The following makes sure we don't go into an endless loop
   -- if no clients are visible. I guess that case could be handled better,
   -- but meh
   local num_tags = #scr:tags()
   for i=1, num_tags do
     awful.tag.viewidx(step, scr)
     if #awful.client.visible(s) == 0 then
       return
     end
   end
end

(I also replaced awful.tag.visible with awful.client.visible)

Uli

-- 
"Why make things difficult, when it is possible to make them cryptic
and totally illogical, with just a little bit more effort?" -- A. P. J.

-- 
To unsubscribe, send mail to [email protected].

Reply via email to