--   This file is part of Reno desktop.
--
--  Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
--
--  Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>. 
-- Static set of tags that you find in the default awesomewm config
local awful = require("awful")
local gears = require("gears")
awful.screen.connect_for_each_screen(function(s)
    -- Clear tags
    for _, tag in pairs(s.tags) do
        tag:delete()
    end
    -- Add 9 default tags
    awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s, 
        awful.layout.suit.floating)
end)
-- keybindings for tags
local keys = root.keys()
keys = gears.table.join(keys,
    awful.key({global.modkey}, "Left", 
        awful.tag.viewprev,
    {description = "view next tag", group = "tag"}),
    awful.key({global.modkey}, "Right",
        awful.tag.viewnext,
    {description = "view previous tag", group = "tag"}))

for i = 1,9 do
    keys = gears.table.join(keys,
        awful.key({global.modkey}, "#"..i+9,
            function()
                local tag = awful.screen.focused().tags[i]
                if tag then
                    tag:view_only()
                end
            end,
        {description = "view tag #"..i, group = "tag"}),
        awful.key({global.modkey, "Control"}, "#"..i+9,
            function()
                local tag = awful.screen.focused().tags[i]
                if tag then
                    awful.tag.viewtoggle(tag)
                end
            end,
        {description = "toggle tag #"..i, group = "tag"}),
        awful.key({global.modkey, "Shift"}, "#"..i+9,
            function()
                if client.focus then
                    local tag = awful.screen.focused().tags[i]
                    if tag then
                        client.focus:move_to_tag(tag)
                    end
                end
            end,
        {description = "move client to tag #"..i, group = "tag"}),
        awful.key({global.modkey, "Shift", "Control"}, "#"..i+9,
            function()
                if client.focus then
                    local tag = awful.screen.focused().tags[i]
                    if tag then
                        client.focus:move_to_tag(tag)
                    end
                end
            end,
        {description = "toggle client on tag #"..i, group = "tag"}))
end
root.keys(keys)
