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:
parent
61d5bda37a
commit
825e012442
|
@ -52,6 +52,9 @@ fg_focus = "#ffffff"
|
||||||
border_focus = bg_focus
|
border_focus = bg_focus
|
||||||
border_marked = "#91231C"
|
border_marked = "#91231C"
|
||||||
|
|
||||||
|
bg_urgent = "#ff0000"
|
||||||
|
fg_urgent = "#ffffff"
|
||||||
|
|
||||||
-- Define if we want to use titlebar on all applications
|
-- Define if we want to use titlebar on all applications
|
||||||
use_titlebar = false
|
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({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
|
||||||
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
|
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
|
||||||
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
|
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
|
-- Create a tasklist widget
|
||||||
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
|
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
|
||||||
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
|
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({ }, 4, function () awful.client.focusbyidx(1) end))
|
||||||
mytasklist:mouse_add(mouse({ }, 5, 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
|
-- Create a textbox widget
|
||||||
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
|
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
|
||||||
|
|
|
@ -921,35 +921,48 @@ end
|
||||||
-- @param t The tag.
|
-- @param t The tag.
|
||||||
-- @param bg_focus The background color for selected tag.
|
-- @param bg_focus The background color for selected tag.
|
||||||
-- @param fg_focus The foreground 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.
|
-- @return A string to print.
|
||||||
function P.widget.taglist.label.all(t, bg_focus, fg_focus)
|
function P.widget.taglist.label.all(t, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||||
local text = ""
|
local text
|
||||||
local background = ""
|
local background = ""
|
||||||
local sel = client.focus_get()
|
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
|
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\""
|
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarefw.png\""
|
||||||
else
|
end
|
||||||
for k, c in pairs(client.get()) do
|
for k, c in pairs(client.get()) do
|
||||||
if c:istagged(t) then
|
if c:istagged(t) then
|
||||||
|
if not (sel and sel:istagged(t)) then
|
||||||
background = "resize=\"true\" image=\"@AWESOME_ICON_PATH@/taglist/squarew.png\""
|
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
|
end
|
||||||
end
|
end
|
||||||
if t.selected then
|
if bg_color and fg_color then
|
||||||
text = "<bg "..background.." color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..P.escape(t.name).."</span> "
|
text = "<bg "..background.." color='"..bg_color.."'/> <span color='"..fg_color.."'>"..P.escape(t.name).."</span> "
|
||||||
else
|
else
|
||||||
text = " <bg "..background.." />"..P.escape(t.name).." "
|
text = " <bg "..background.." />"..P.escape(t.name).." "
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
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 = ""
|
local text = ""
|
||||||
if c.floating then
|
if c.floating then
|
||||||
text = "<bg image=\"@AWESOME_ICON_PATH@/tasklist/floatingw.png\" align=\"right\"/>"
|
text = "<bg image=\"@AWESOME_ICON_PATH@/tasklist/floatingw.png\" align=\"right\"/>"
|
||||||
end
|
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> "
|
text = text .. " <bg color='"..bg_focus.."'/><span color='"..fg_focus.."'>"..P.escape(c.name).."</span> "
|
||||||
else
|
else
|
||||||
text = text .. " "..P.escape(c.name).." "
|
text = text .. " "..P.escape(c.name).." "
|
||||||
|
@ -965,9 +978,11 @@ end
|
||||||
-- @param screen The screen we are drawing on.
|
-- @param screen The screen we are drawing on.
|
||||||
-- @param bg_focus The background color for focused client.
|
-- @param bg_focus The background color for focused client.
|
||||||
-- @param fg_focus The foreground 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.
|
-- @return A string to pring.
|
||||||
function P.widget.tasklist.label.allscreen(c, screen, 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)
|
return widget_tasklist_label_common(c, bg_focus, fg_focus, bg_urgent, fg_urgent)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return labels for a tasklist widget with clients from all tags.
|
--- 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 screen The screen we are drawing on.
|
||||||
-- @param bg_focus The background color for focused client.
|
-- @param bg_focus The background color for focused client.
|
||||||
-- @param fg_focus The foreground 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.
|
-- @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
|
-- Only print client on the same screen as this widget
|
||||||
if c.screen ~= screen then return end
|
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
|
end
|
||||||
|
|
||||||
--- Return labels for a tasklist widget with clients from currently selected tags.
|
--- 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 screen The screen we are drawing on.
|
||||||
-- @param bg_focus The background color for focused client.
|
-- @param bg_focus The background color for focused client.
|
||||||
-- @param fg_focus The foreground 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.
|
-- @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
|
-- Only print client on the same screen as this widget
|
||||||
if c.screen ~= screen then return end
|
if c.screen ~= screen then return end
|
||||||
for k, t in pairs(tag.get(screen)) do
|
for k, t in pairs(tag.get(screen)) do
|
||||||
if t.selected and c:istagged(t) then
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue