From 0397854775c10b804312929110666d5415c26b88 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 11 Aug 2008 04:26:31 +0300 Subject: [PATCH] awful: add no empty show for taglist Signed-off-by: Julien Danjou --- lib/awful.lua.in | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/awful.lua.in b/lib/awful.lua.in index 8d2f20be8..c3f2a3eeb 100644 --- a/lib/awful.lua.in +++ b/lib/awful.lua.in @@ -1069,6 +1069,49 @@ function widget.taglist.label.all(t, args) return text end +--- Return labels for a taglist widget with all *non empty* tags from screen. +-- It returns the tag name and set a special +-- foreground and background color for selected tags. +-- @param t The tag. +-- @param args The arguments table. +-- bg_focus The background color for selected tag. +-- fg_focus The foreground color for selected tag. +-- bg_urgent The background color for urgent tags. +-- fg_urgent The foreground color for urgent tags. +-- @return A string to print. +function widget.taglist.label.noempty(t, args) + if #t.clients > 0 then + if not args then args = {} end + local fg_focus = args.fg_focus or theme.fg_focus + local bg_focus = args.bg_focus or theme.bg_focus + local fg_urgent = args.fg_urgent or theme.fg_urgent + local bg_urgent = args.bg_urgent or theme.bg_urgent + local bg_color = nil + local fg_color = nil + local text + + if t.selected then + bg_color = bg_focus + fg_color = fg_focus + end + if bg_urgent and fg_urgent then + for k, c in pairs(t.clients) do + if c.urgent then + bg_color = bg_urgent + fg_color = fg_urgent + break + end + end + end + if fg_color and bg_color then + text = " " .. escape(t.name) .. " " + else + text = " " .. escape(t.name) .. " " + end + return text + end +end + local function widget_tasklist_label_common(c, args) if not args then args = {} end local fg_focus = args.fg_focus or theme.fg_focus