Add support for 'exec_once' property, add basic support for tag 'add' and 'selected' smart hooks

This commit is contained in:
Emmanuel Lepage Vallee 2013-03-08 00:33:34 -05:00
parent 4779fcbf45
commit 916d8e600e
2 changed files with 23 additions and 14 deletions

View File

@ -110,6 +110,7 @@ tyranical.tags = {
-- icon = utils.tools.invertedIconPath("folder.png") , -- icon = utils.tools.invertedIconPath("folder.png") ,
screen = 1,--config.data().scr.pri , screen = 1,--config.data().scr.pri ,
layout = awful.layout.suit.tile , layout = awful.layout.suit.tile ,
exec_once = {"dolphin"} ,
class = { class = {
"Thunar" , "Konqueror" , "Dolphin" , "ark" , "Nautilus", } "Thunar" , "Konqueror" , "Dolphin" , "ark" , "Nautilus", }
} , } ,

View File

@ -12,18 +12,10 @@ local module = {}
-------------------------------INIT------------------------------ -------------------------------INIT------------------------------
local signals = { local signals = {
"property::exclusive", "property::exclusive" , "property::init" , "property::volatile" ,
"property::init", "property::focus_on_new" , "property::instances" , "property::match" ,
"property::volatile", "property::class" , "property::spawn" , "property::position" ,
"property::focus_on_new", "property::force_screen" , "property::max_clients", "property::exec_once",
"property::instances",
"property::match",
"property::class",
"property::spawn",
"property::position",
"property::force_screen",
"property::max_clients",
} }
for _,sig in ipairs(signals) do for _,sig in ipairs(signals) do
capi.tag.add_signal(sig) capi.tag.add_signal(sig)
@ -35,13 +27,23 @@ local class_client,matches_client = {},{}
--------------------------TYRANIC LOGIC-------------------------- --------------------------TYRANIC LOGIC--------------------------
--Called when a tag is selected/unselected
local function on_selected_change(tag,data)
if data.exec_once and tag.selected and not data._init_done then
for k,v in ipairs(type(data.exec_once) == "string" and {data.exec_once} or data.exec_once) do
awful.util.spawn(v, false)
end
data._init_done = true
end
end
--Turn tags -> matches into matches -> tags --Turn tags -> matches into matches -> tags
local function fill_tyranic(tab_in,tab_out,value) local function fill_tyranic(tab_in,tab_out,value)
if tab_in and tab_out then if tab_in and tab_out then
for i=1,#tab_in do for i=1,#tab_in do
local low = string.lower(tab_in[i]) local low = string.lower(tab_in[i])
local tmp = tab_out[low] or {tags={},properties={}} local tmp = tab_out[low] or {tags={},properties={}}
value.instances = value.instances or {} value.instances= value.instances or {}
tmp.tags[#tmp.tags+1] = value tmp.tags[#tmp.tags+1] = value
tab_out[low] = tmp tab_out[low] = tmp
end end
@ -160,7 +162,7 @@ capi.client.connect_signal("untagged", function (c, t)
end) end)
-- awful.tag.withcurrent = function() end --Disable automatic tag insertion -- awful.tag.withcurrent = function() end --Disable automatic tag insertion
awful.tag.withcurrent = function(c, startup) awful.tag.withcurrent,awful.tag._add = function(c, startup)
local tags,old_tags = {},c:tags() local tags,old_tags = {},c:tags()
--Safety to prevent --Safety to prevent
for k, t in ipairs(old_tags) do for k, t in ipairs(old_tags) do
@ -178,6 +180,12 @@ awful.tag.withcurrent = function(c, startup)
end end
end end
c:tags(tags) c:tags(tags)
end,awful.tag.add
awful.tag.add = function(tag,props)
local t = awful.tag._add(tag,props)
t:connect_signal("property::selected", function(t) on_selected_change(t,props) end)
return t
end end
--------------------------OBJECT GEARS--------------------------- --------------------------OBJECT GEARS---------------------------