From 725137c62c0f676ba719c874af38963fb47f1aad Mon Sep 17 00:00:00 2001 From: Drauthius Date: Sat, 9 Jan 2016 21:11:29 +0100 Subject: [PATCH] Added keys with the same name as the tag name. Makes it easier to move tag numbers around without having to change the rules. --- doc/index.html | 9 ++++++--- init.lua | 11 +++++++++-- rc.lua.patch | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/doc/index.html b/doc/index.html index 24fa941..b95bfd8 100644 --- a/doc/index.html +++ b/doc/index.html @@ -106,7 +106,9 @@
    table - A list of all created tags. + A list of all created tags. Tags are assigned numeric values + corresponding to the input list, and all tags with non-numerical names are + also assigned to a key with the same name.
@@ -119,7 +121,8 @@ -- "www" is the second tag on screen 1 with the floating layout. { name = "www" }, -- Third tag is named "3" on screen 1 with the floating layout. - {}) + {}) + -- tags[2] and tags["www"] both refer to the same tag. @@ -213,7 +216,7 @@
generated by LDoc 1.4.3 -Last updated 2016-01-03 19:41:48 +Last updated 2016-01-09 21:09:20
diff --git a/init.lua b/init.lua index 914be6d..d358d6b 100644 --- a/init.lua +++ b/init.lua @@ -49,7 +49,9 @@ local sharedtags = { -- defaults to the first layout. The `screen` value sets the starting screen -- for the tag and defaults to the first screen. The tags will be sorted in this -- order in the default taglist. --- @treturn table A list of all created tags. +-- @treturn table A list of all created tags. Tags are assigned numeric values +-- corresponding to the input list, and all tags with non-numerical names are +-- also assigned to a key with the same name. -- @usage local tags = sharedtags( -- -- "main" is the first tag starting on screen 2 with the tile layout. -- { name = "main", layout = awful.layout.suit.tile, screen = 2 }, @@ -57,6 +59,7 @@ local sharedtags = { -- { name = "www" }, -- -- Third tag is named "3" on screen 1 with the floating layout. -- {}) +-- -- tags[2] and tags["www"] both refer to the same tag. function sharedtags.new(def) local tags = {} @@ -67,6 +70,11 @@ function sharedtags.new(def) sharedtagindex = i }) + -- Create an alias between the index and the name. + if t.name and type(t.name) ~= "number" then + tags[t.name] = tags[i] + end + -- If no tag is selected for this screen, then select this one. if not awful.tag.selected(awful.tag.getscreen(tags[i])) then awful.tag.viewonly(tags[i]) -- Updates the history as well. @@ -108,7 +116,6 @@ function sharedtags.movetag(tag, screen) local newtag = awful.tag.find_fallback(oldscreen) if newtag then awful.tag.viewonly(newtag) - else end end else diff --git a/rc.lua.patch b/rc.lua.patch index 0174e8c..2604be1 100644 --- a/rc.lua.patch +++ b/rc.lua.patch @@ -90,7 +90,7 @@ https://github.com/Drauthius/awesome-sharedtags + -- Set Firefox to always map on tag number 2. -- { rule = { class = "Firefox" }, - -- properties = { tag = tags[1][2] } }, -+ -- properties = { tag = tags[2] } }, ++ -- properties = { tag = tags[2] } }, -- tag = tags["www"] works as well } -- }}}