diff --git a/impl/common/tag.lua b/impl/common/tag.lua new file mode 100644 index 0000000..f46b847 --- /dev/null +++ b/impl/common/tag.lua @@ -0,0 +1,27 @@ +local radical = require("radical") +local capi = { screen = screen, } +local awful = require( "awful" ) +local module = {} + +local function createTagList(aScreen) + local tagList = radical.context({autodiscard = true}) + for _, v in ipairs(awful.tag.gettags(aScreen)) do + tagList:add_item({text = v.name,icon=awful.tag.geticon(v)}) + end + return tagList +end + +function module.listTags() + if capi.screen.count() == 1 then + return createTagList(1) + else + local screenSelect = radical.context(({autodiscard = true})) + for i=1, capi.screen.count() do + screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i)}) + end + return screenSelect + end +end + +return setmetatable(module, { __call = function(_, ...) return module.listTags(...) end }) +-- kate: space-indent on; indent-width 2; replace-tabs on; \ No newline at end of file diff --git a/impl/tasklist/client_menu.lua b/impl/tasklist/client_menu.lua index 3fb178d..69344c9 100644 --- a/impl/tasklist/client_menu.lua +++ b/impl/tasklist/client_menu.lua @@ -7,28 +7,10 @@ local beautiful = require( "beautiful" ) local awful = require( "awful" ) local util = require( "awful.util" ) local wibox = require( "wibox" ) +local listTags = require( "radical.impl.common.tag" ).listTags local module,mainMenu = {},nil -local function listTags() - function createTagList(aScreen) - local tagList = radical.context({autodiscard = true}) - for _, v in ipairs(awful.tag.gettags(aScreen)) do - tagList:add_item({text = v.name,icon=awful.tag.geticon(v)}) - end - return tagList - end - if capi.screen.count() == 1 then - return createTagList(1) - else - local screenSelect = radical.context(({autodiscard = true})) - for i=1, capi.screen.count() do - screenSelect:add_item({text="Screen "..i , sub_menu = createTagList(i)}) - end - return screenSelect - end -end - local function createNewTag() return awful.tag.add(module.client.class,{}) end