Hi all,
I've finally polished off the windowcycle script I've been working on to
the point where it's useable for me, so I thought I'd send it here to see
if anyone is interested/has better ideas. It just exports two functions
windowcycle.cycle and windowcycle.visible_cycle. They cycle through client
windows in the current workspace, with the latter function only going
through visible windows. The demo bindings basically allow this to mimic
the behavior of my fvwm configuration.
These functions have one extra-hokey aspect, which is that they are
hardcoded to ignore windows with "xclock" in their name. This really ought
to be configurable, but I'm lazy and don't know any lua to speak of. And I
use xclocks.
--
David Roundy
-- windowcycle.lua -- by David Roundy
--
-- Example usage:
--
-- dopath("windowcycle")
--
-- defbindings("WFrame-on-WIonWS", {
-- kpress(MOD1.."Tab", "windowcycle.cycle(_)"),
-- kpress("Control+Tab", "windowcycle.visible_cycle(_)");
-- })
local windowcycle={}
_G["windowcycle"]=windowcycle
local isnotxclock
local isalsovisible
function isnotxclock(w)
return (not string.find(WRegion.name(w), "xclock", 1, true))
-- and WRegion.is_mapped(w)
end
function isalsovisible(w)
return (not string.find(WRegion.name(w), "xclock", 1, true))
and WRegion.is_mapped(w)
end
local generic_cycle
function generic_cycle(frame, isok)
local allwins = ioncore.clientwin_list()
local ws=ioncore.find_manager(frame, "WGenWS")
if not obj_is(ws, "WIonWS") then
warn("Expecting WIonWS")
return
end
local current_window = WMPlex.lcurrent(frame, 1)
foundit = 0
for _, w in allwins do
-- mod_query.warn(frame, "is it here? "..WRegion.name(w))
if ioncore.find_manager(w, "WGenWS") == ws and isok(w) then
-- mod_query.warn(frame, "is it here?")
if foundit == 1 then
-- mod_query.warn(frame, "bazbar")
w:goto()
return
end
if w == current_window then
-- mod_query.warn(frame, "zing")
foundit = 1
end
end
end
-- Okay, the current window must be last in the list
for _, w in allwins do
if ioncore.find_manager(w, "WGenWS") == ws and isok(w) then
w:goto()
return
end
end
end
function windowcycle.cycle(frame)
generic_cycle(frame, isnotxclock)
end
function windowcycle.visible_cycle(frame)
generic_cycle(frame, isalsovisible)
end