From e17f7b879c12df1405af829100920cdf25e5c3b1 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 14 Jun 2015 13:07:36 +0200 Subject: [PATCH] shifty: fusion delete/rename tag function When a tag is empty, delete it, otherwise, rename it. --- lib/shifty.lua | 3 ++- rc/tags.lua | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/shifty.lua b/lib/shifty.lua index 70cef34..7f21602 100644 --- a/lib/shifty.lua +++ b/lib/shifty.lua @@ -449,7 +449,7 @@ function del(tag) for i, c in ipairs(clients) do if c.sticky then sticky = sticky + 1 end end - if #clients > sticky then return end + if #clients > sticky then return false end -- store index for later index_cache[scr][getname(t)] = idx @@ -469,6 +469,7 @@ function del(tag) -- FIXME: what is this for?? if capi.client.focus then capi.client.focus:raise() end + return true end --is_client_tagged : replicate behavior in tag.c - returns true if the diff --git a/rc/tags.lua b/rc/tags.lua index fd4dbb1..a9c4bcd 100644 --- a/rc/tags.lua +++ b/rc/tags.lua @@ -93,6 +93,12 @@ shifty.config.defaults = { shifty.taglist = config.taglist -- Set in widget.lua shifty.init() +local tag_del_or_rename = function(tag) + if not shifty.del(tag) then + shifty.rename(tag) + end +end + config.keys.global = awful.util.table.join( config.keys.global, keydoc.group("Tag management"), @@ -121,8 +127,8 @@ config.keys.global = awful.util.table.join( end, "Send all tags to next screen"), awful.key({ modkey }, 0, shifty.add, "Create a new tag"), - awful.key({ modkey, "Shift" }, 0, shifty.del, "Delete tag"), - awful.key({ modkey, "Control" }, 0, shifty.rename, "Rename tag")) + awful.key({ modkey, "Shift" }, 0, tag_del_or_rename), + awful.key({ modkey, "Control" }, 0, tag_del_or_rename, "Rename or delete tag")) -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it works on any keyboard layout.