local awful = require('awful') module = {} function module.delete_tag() local t = awful.screen.focused().selected_tag if not t then return end t:delete() end local tmpcounter = 0 function module.add_tag(name, properties, switchto, force) local p = (type(properties) == "table" and properties) or {} if not name then name = name or string.format("t%d", tmpcounter) tmpcounter = tmpcounter + 1 end if not awful.tag.find_by_name(p.screen, name) or force then p.screen = (p.screen or (client.focus and client.focus.screen) or awful.screen.focused()) local t = awful.tag.add(name, p) if switchto then t:view_only() end return t else local text = "A tag with name \"" .. name .. "\" already exists" if p.screen then text = text .. " (on screen " .. p.screen.name .. ")" end naughty.notify({ preset = naughty.config.presets.low, title = "Add a new tag", text = text }) end end function module.rename_tag() awful.prompt.run { prompt = "New tag name: ", textbox = awful.screen.focused().mypromptbox.widget, exe_callback = function(new_name) if not new_name or #new_name == 0 then return end local t = awful.screen.focused().selected_tag if t then t.name = new_name end end } end function module.move_to_new_tag(clnt, properties, volatile, switchto, force) local c = clnt or client.focus if not c then return end local p = (type(properties) == "table" and properties) or {} local s = p.screen or c.screen local t = module.add_tag(c.class, { screen = s, volatile = volatile, }, switchto, force) c:move_to_tag(t) end function module.copy_tag() local t = awful.screen.focused().selected_tag if not t then return end local clients = t:clients() local t2 = awful.tag.add(t.name, awful.tag.getdata(t)) t2:clients(clients) t2:view_only() end function module.collect_orphan_clients_to_tag(name) local orphans = {} for _,c in ipairs(client.get()) do if #c:tags() == 0 then orphans[#orphans+1] = c end end if #orphans == 0 then naughty.notify({text="No orphan clients found."}) return end local t = awful.tag.find_by_name(nil, name) if not t then t = module.add_tag("orphans", { volatile = true, screen = awful.screen.focused(), }, true) end for _,c in ipairs(orphans) do c:move_to_tag(t) end end return module