Add 'urgent' property to tags

This commit is contained in:
Emmanuel Lepage Vallee 2014-11-01 18:19:12 -04:00 committed by Emmanuel Lepage Vallee
parent d688ebe6cd
commit b292b09328
1 changed files with 35 additions and 0 deletions

35
lib/awful/tag.lua.in Normal file → Executable file
View File

@ -630,7 +630,40 @@ capi.client.connect_signal("manage", function(c)
c:connect_signal("property::screen", tag.withcurrent) c:connect_signal("property::screen", tag.withcurrent)
end) end)
-- Keep track of the number of urgent client
local function update_urgent(c,t)
local modif = c.urgent == true and 1 or -1
local count = tag.getproperty(t,"urgent_count") or 0
count = (count + modif) >= 0 and (count + modif) or 0
tag.setproperty(t,"urgent" , count > 0)
tag.setproperty(t,"urgent_count", count )
end
-- Update the urgent counter when a client is tagged
local function client_tagged(c,t)
if c.urgent then
update_urgent(c,t)
end
end
-- Update the urgent counter when a client is untagged
local function client_untagged(c,t)
if c.urgent then
update_urgent(c,t)
end
end
-- Count the urgent clients
local function urgent_callback(c)
for k,t in ipairs(c:tags()) do
update_urgent(c,t)
end
end
capi.client.connect_signal("property::urgent", urgent_callback)
capi.client.connect_signal("manage", tag.withcurrent) capi.client.connect_signal("manage", tag.withcurrent)
capi.client.add_signal("untagged", client_untagged)
capi.client.add_signal("tagged", client_tagged)
capi.tag.connect_signal("request::select", tag.viewonly) capi.tag.connect_signal("request::select", tag.viewonly)
capi.tag.add_signal("property::hide") capi.tag.add_signal("property::hide")
@ -642,6 +675,8 @@ capi.tag.add_signal("property::nmaster")
capi.tag.add_signal("property::windowfact") capi.tag.add_signal("property::windowfact")
capi.tag.add_signal("property::screen") capi.tag.add_signal("property::screen")
capi.tag.add_signal("property::index") capi.tag.add_signal("property::index")
capi.tag.add_signal("property::urgent")
capi.tag.add_signal("property::urgent_count")
capi.screen.add_signal("tag::history::update") capi.screen.add_signal("tag::history::update")
for s = 1, capi.screen.count() do for s = 1, capi.screen.count() do