[PATCH] Allow widgets on the left side.

2 views
Skip to first unread message

dcurtis

unread,
Mar 17, 2009, 7:03:24 PM3/17/09
to wmii...@googlegroups.com
This patch allows widgets to exist in the lbar. There is an extra
parameter that specifies "rbar" (default) or "lbar"

Had to add a bit of code to allow widgets to be persistent in the lbar
on a restart.
---
core/wmii.lua | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/core/wmii.lua b/core/wmii.lua
index 8d98924..4816bee 100644
--- a/core/wmii.lua
+++ b/core/wmii.lua
@@ -1049,6 +1049,11 @@ function update_displayed_tags_on_screen(s)
old[v] = nil
end

+ -- we can now have widgets in the lbar
+ for i,v in pairs(widgets) do
+ old[v.name] = nil
+ end
+
-- anything left in the old table should be removed now
for i,v in pairs(old) do
if v then
@@ -1781,7 +1786,7 @@ widgets = {}
-- examples:
-- widget = wmii.widget:new ("999_clock")
-- widget = wmii.widget:new ("999_clock", clock_event_handler)
-function widget:new (name, fn)
+function widget:new (name, fn, bar)
local o = {}

if type(name) == "string" then
@@ -1789,6 +1794,7 @@ function widget:new (name, fn)
if type(fn) == "function" then
o.fn = fn
end
+ o.bar = bar or "rbar"
else
error ("expected name followed by an optional function as arguments")
end
@@ -1826,9 +1832,9 @@ function widget:show (txt, colors)
towrite = colors .. " " .. towrite
end
if not self.txt then
- create ("/rbar/" .. self.name, towrite)
+ create ('/'..self.bar..'/'.. self.name, towrite)
else
- write ("/rbar/" .. self.name, towrite)
+ write ('/'..self.bar..'/'.. self.name, towrite)
end
self.txt = txt
end
@@ -1837,7 +1843,7 @@ end
-- hides a widget and removes it from the bar
function widget:hide ()
if self.txt then
- remove ("/lbar/" .. self.name)
+ remove ('/'..self.bar ..'/'.. self.name)
self.txt = nil
end
end
--
1.6.2

Bart Trojanowski

unread,
Mar 17, 2009, 10:19:06 PM3/17/09
to wmii...@googlegroups.com, dcu...@cs.uiowa.edu
* dcurtis <dcu...@cs.uiowa.edu> [090317 19:09]:

> This patch allows widgets to exist in the lbar. There is an extra
> parameter that specifies "rbar" (default) or "lbar"
>
> Had to add a bit of code to allow widgets to be persistent in the lbar
> on a restart.

Hmm... ok.

> @@ -1049,6 +1049,11 @@ function update_displayed_tags_on_screen(s)
> old[v] = nil
> end
>
> + -- we can now have widgets in the lbar
> + for i,v in pairs(widgets) do
> + old[v.name] = nil
> + end

Don't we only want to do this for the widgets that are on the lbar ?

The rest looks good.

-Bart

--
WebSig: http://www.jukie.net/~bart/sig/

Reply all
Reply to author
Forward
0 new messages