Handle urgency hint in awful.

Add option bg_urgent and fg_urgent and handle them
appropiately in tasklist and taglist widgets.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Alex Cornejo 2008-07-31 17:04:35 -04:00 committed by Julien Danjou
parent 61d5bda37a
commit 825e012442
2 changed files with 40 additions and 18 deletions

View File

@ -52,6 +52,9 @@ fg_focus = "#ffffff"
border_focus = bg_focus
border_marked = "#91231C"
bg_urgent = "#ff0000"
fg_urgent = "#ffffff"
-- Define if we want to use titlebar on all applications
use_titlebar = false
@ -87,14 +90,14 @@ mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.s
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
function mytaglist.label(t) return awful.widget.taglist.label.all(t, bg_focus, fg_focus) end
function mytaglist.label(t) return awful.widget.taglist.label.all(t, bg_focus, fg_focus, bg_urgent, fg_urgent) end
-- Create a tasklist widget
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
function mytasklist.label(c, screen) return awful.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus) end
function mytasklist.label(c, screen) return awful.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent) end
-- Create a textbox widget
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })

View File

@ -921,35 +921,48 @@ end
-- @param t The tag.
-- @param bg_focus The background color for selected tag.
-- @param fg_focus The foreground color for selected tag.
-- @param bg_urgent The background color for urgent tags.
-- @param fg_urgent The foreground color for urgent tags.
-- @return A string to print.
function P.widget.taglist.label.all(t, bg_focus, fg_focus)
local text = ""
function P.widget.taglist.label.all(t, bg_focus, fg_focus, bg_urgent, fg_urgent)
local text
local background = ""
local sel = client.focus_get()
local bg_color = nil
local fg_color = nil
local has_color = t.selected
if sel and sel:istagged(t) then
bg_color = bg_focus
fg_color = fg_focus
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarefw.png\""
else
for k, c in pairs(client.get()) do
if c:istagged(t) then
end
for k, c in pairs(client.get()) do
if c:istagged(t) then
if not (sel and sel:istagged(t)) then
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarew.png\""
break
end
if c.urgent and bg_urgent and fg_urgent then
bg_color = bg_urgent
fg_color = fg_urgent
end
end
end
if t.selected then
text = "<bg "..background.." color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..P.escape(t.name).."</span> "
if bg_color and fg_color then
text = "<bg "..background.." color='"..bg_color.."'/> <span color='"..fg_color.."'>"..P.escape(t.name).."</span> "
else
text = " <bg "..background.." />"..P.escape(t.name).." "
end
return text
end
local function widget_tasklist_label_common(c, bg_focus, fg_focus)
local function widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
local text = ""
if c.floating then
text = "<bg image=\"@AWESOME_ICON_PATH@/tasklist/floatingw.png\" align=\"right\"/>"
end
if client.focus_get() == c then
if c.urgent and bg_urgent and fg_urgent then
text = text .. " <bg color='"..bg_urgent.."'/><span color='"..fg_urgent.."'>"..P.escape(c.name).."</span> "
elseif client.focus_get() == c then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..fg_focus.."'>"..P.escape(c.name).."</span> "
else
text = text .. " "..P.escape(c.name).." "
@ -965,9 +978,11 @@ end
-- @param screen The screen we are drawing on.
-- @param bg_focus The background color for focused client.
-- @param fg_focus The foreground color for focused client.
-- @param bg_urgent The background color for urgent clients.
-- @param fg_urgent The foreground color for urgent clients.
-- @return A string to pring.
function P.widget.tasklist.label.allscreen(c, screen, bg_focus, fg_focus)
return widget_tasklist_label_common(c, bg_focus, fg_focus)
function P.widget.tasklist.label.allscreen(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
end
--- Return labels for a tasklist widget with clients from all tags.
@ -978,11 +993,13 @@ end
-- @param screen The screen we are drawing on.
-- @param bg_focus The background color for focused client.
-- @param fg_focus The foreground color for focused client.
-- @param bg_urgent The background color for urgent clients.
-- @param fg_urgent The foreground color for urgent clients.
-- @return A string to pring.
function P.widget.tasklist.label.alltags(c, screen, bg_focus, fg_focus)
function P.widget.tasklist.label.alltags(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
-- Only print client on the same screen as this widget
if c.screen ~= screen then return end
return widget_tasklist_label_common(c, bg_focus, fg_focus)
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
end
--- Return labels for a tasklist widget with clients from currently selected tags.
@ -993,13 +1010,15 @@ end
-- @param screen The screen we are drawing on.
-- @param bg_focus The background color for focused client.
-- @param fg_focus The foreground color for focused client.
-- @param bg_urgent The background color for urgent clients.
-- @param fg_urgent The foreground color for urgent clients.
-- @return A string to pring.
function P.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus)
function P.widget.tasklist.label.currenttags(c, screen, bg_focus, fg_focus, bg_urgent, fg_urgent)
-- Only print client on the same screen as this widget
if c.screen ~= screen then return end
for k, t in pairs(tag.get(screen)) do
if t.selected and c:istagged(t) then
return widget_tasklist_label_common(c, bg_focus, fg_focus)
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
end
end
end