From b0aedcda674489002c4faee01b72e1ade049c7df Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 14 Apr 2016 23:45:04 -0400 Subject: [PATCH] awful.rules: Add `new_tag` property Create a new dynamic tag for the client. --- lib/awful/rules.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index 4ff94170a..a011590f6 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -249,6 +249,7 @@ rules.extra_properties = {} -- By default, the table has the following functions: -- -- * tag +-- * new_tag -- -- @tfield table awful.rules.high_priority_properties rules.high_priority_properties = {} @@ -305,6 +306,32 @@ function rules.extra_properties.geometry(c, _, props) c:geometry(new_geo) --TODO use request::geometry end +--- Create a new tag based on a rule. +-- @tparam client c The client +-- @tparam boolean|function|string value The value. +-- @treturn tag The new tag +function rules.high_priority_properties.new_tag(c, value) + local ty = type(value) + local t = nil + + if ty == "boolean" then + -- Create a new tag named after the client class + t = atag.add(c.class or "N/A", {screen=c.screen, volatile=true}) + elseif ty == "string" then + -- Create a tag named after "value" + t = atag.add(value, {screen=c.screen, volatile=true}) + elseif ty == "table" then + -- Assume a table of tags properties + t = atag.add(value.name or c.class or "N/A", value) + else + assert(false) + end + + add_to_tag(c, t) + + return t +end + --- Apply properties and callbacks to a client. -- @client c The client. -- @tab props Properties to apply.