widget: add the tasklist only on multihead setup

This commit is contained in:
Vincent Bernat 2012-07-07 11:13:47 +02:00
parent a882194432
commit 9040614ea9

View file

@ -122,10 +122,14 @@ tasklist.buttons = awful.util.table.join(
for s = 1, screen.count() do for s = 1, screen.count() do
promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
layoutbox[s] = awful.widget.layoutbox(s) layoutbox[s] = awful.widget.layoutbox(s)
tasklist[s] = awful.widget.tasklist( if screen.count() > 1 then
function(c) tasklist[s] = awful.widget.tasklist(
return awful.widget.tasklist.label.currenttags(c, s) function(c)
end, tasklist.buttons) return awful.widget.tasklist.label.currenttags(c, s)
end, tasklist.buttons)
else
tasklist[s] = ""
end
-- Create the taglist -- Create the taglist
taglist[s] = sharetags.taglist(s, sharetags.label.all, taglist.buttons) taglist[s] = sharetags.taglist(s, sharetags.label.all, taglist.buttons)
@ -137,12 +141,8 @@ for s = 1, screen.count() do
height = 14, height = 14,
}) })
-- Add widgets to the wibox -- Add widgets to the wibox
local onfirst = function(what) local on = function(n, what)
if s == 1 then return what end if s == n or n > screen.count() then return what end
return ""
end
local onsecond = function(what)
if s == 2 or screen.count() == 1 then return what end
return "" return ""
end end
@ -152,14 +152,14 @@ for s = 1, screen.count() do
separator, promptbox[s], separator, promptbox[s],
layout = awful.widget.layout.horizontal.leftright layout = awful.widget.layout.horizontal.leftright
}, },
onfirst(systray), onfirst(separator), on(1, systray), on(1, separator),
datewidget, separator, datewidget, separator,
onsecond(volwidget), onsecond(separator), on(2, volwidget), on(2, separator),
onsecond(batwidget), onsecond(batwidget ~= "" and separator or nil), on(2, batwidget), on(2, batwidget ~= "" and separator or ""),
onsecond(fswidget), onsecond(separator), on(2, fswidget), on(2, separator),
onfirst(memwidget), onfirst(separator), on(1, memwidget), on(1, separator),
onfirst(cpuwidget), onfirst(separator), on(1, cpuwidget), on(1, separator),
tasklist[s], separator, tasklist[s], tasklist ~= "" and separator or "",
layout = awful.widget.layout.horizontal.rightleft } layout = awful.widget.layout.horizontal.rightleft }
end end