reno/widgets/clientcontrols.lua

73 lines
2.9 KiB
Lua
Raw Normal View History

2022-08-31 12:20:58 +00:00
-- 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/>.
-- Basic client control menu
2022-08-25 15:27:31 +00:00
local awmtk2 = require("awmtk2")
local wibox = require("wibox")
local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful")
local menugen = require("context_menu")
return function(args)
2022-09-05 21:54:11 +00:00
local style = awmtk2.create_style("client_controls",
awmtk2.generic.menu,args.style)
2022-08-25 15:27:31 +00:00
local templates = awmtk2.create_template_lib("client_controls",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style)
local move_to_tag = {}
local add_to_tag = {}
awful.screen.connect_for_each_screen(function(s)
table.insert(move_to_tag,{
"Screen "..s.index,
(function()
local t = {}
for k,v in pairs(s.tags) do
table.insert(t,{v.name,function()
if client.focus then
client.focus:tags({v})
end
end})
end
return t
end)()
})
table.insert(add_to_tag,{
"Screen "..s.index,
(function()
local t = {}
for k,v in pairs(s.tags) do
table.insert(t,{v.name,function()
if client.focus then
local tags = client.focus:tags()
for k,tag in pairs(tags) do
if v == tag then
table.remove(tags,k)
client.focus:tags(tags)
return
end
end
table.insert(tags,v)
client.focus:tags(tags)
end
end})
end
return t
end)()
})
end)
local widget = menugen({
items = {
{ "Kill client", function() client.focus:kill() end },
{ "Raise client", function() client.focus:raise() end},
{ "Lower client", function() client.focus:lower() end},
{ "Move to tag", move_to_tag },
{ "Switch on tag", add_to_tag }
},
})
return widget
end