widget: display a minimal tasklist for one-screen setups

We do not have enough space for a complete tasklist on one-screen
setups. Therefore, we just display a minimal ones with just
icons. Since this does not take much space, we display icons for all
tags.
This commit is contained in:
Vincent Bernat 2012-07-09 22:31:31 +02:00
parent 1359929f15
commit d00ba1f4cd

View file

@ -173,10 +173,13 @@ for s = 1, screen.count() do
promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
layoutbox[s] = awful.widget.layoutbox(s)
awful.widget.layout.margins[layoutbox[s]] = { left = 5 }
if screen.count() > 1 then
tasklist[s] = awful.widget.tasklist(
function(c)
local title, color, _, icon = awful.widget.tasklist.label.currenttags(c, s)
local fn = awful.widget.tasklist.label.currenttags
if screen.count() == 1 then
fn = awful.widget.tasklist.label.alltags
end
local title, color, _, icon = fn(c, s)
-- Try to search for an alternative icon if none is available
for _, name in pairs({c.class, c.instance}) do
if not icon and title and name then
@ -195,11 +198,12 @@ for s = 1, screen.count() do
end
end
-- Use our icon and don't set the status image.
if screen.count() > 1 then
return title, color, nil, icon
end, tasklist.buttons)
else
tasklist[s] = ""
elseif icon then
return "", color, nil, icon
end
end, tasklist.buttons)
-- Create the taglist
taglist[s] = sharetags.taglist(s, sharetags.label.all, taglist.buttons)
@ -230,7 +234,7 @@ for s = 1, screen.count() do
on(1, netgraph.widget), on(1, netwidget), on(1, separator),
on(1, memwidget), on(1, separator),
on(1, cpuwidget), on(1, separator),
tasklist[s], tasklist[s] ~= "" and separator or "",
tasklist[s], separator,
layout = awful.widget.layout.horizontal.rightleft }
end