153 lines
4.7 KiB
Lua
153 lines
4.7 KiB
Lua
local awful = require("awful")
|
|
local gears = require("gears")
|
|
local wibox = require("wibox")
|
|
local menu = require("widgets.polymenu")
|
|
local move_screentags = {}
|
|
local toggle_screentags = {}
|
|
awful.screen.connect_for_each_screen(function(s)
|
|
local move_tags = {}
|
|
local toggle_tags = {}
|
|
for _,tag in pairs(s.tags) do
|
|
table.insert(move_tags,{
|
|
tag.name,
|
|
function()
|
|
if client.focus then
|
|
client.focus:tags({tag})
|
|
end
|
|
end
|
|
})
|
|
table.insert(toggle_tags,{
|
|
tag.name,
|
|
function()
|
|
if client.focus then
|
|
local tags = client.focus:tags()
|
|
for k,v in pairs(tags) do
|
|
if v == tag then
|
|
table.remove(tags,k)
|
|
client.focus:tags(tags)
|
|
return
|
|
end
|
|
end
|
|
table.insert(tags,tag)
|
|
client.focus:tags(tags)
|
|
end
|
|
end
|
|
})
|
|
end
|
|
table.insert(move_screentags,{
|
|
"Screen "..tostring(s.index),
|
|
move_tags
|
|
})
|
|
table.insert(toggle_screentags,{
|
|
"Screen "..tostring(s.index),
|
|
toggle_tags
|
|
})
|
|
end)
|
|
local controls_widget = wibox.widget {
|
|
forced_width = 72,
|
|
forced_height = 24,
|
|
layout = wibox.layout.fixed.horizontal,
|
|
}
|
|
-- To conserve memory we keep one menu at a time
|
|
local menu_widget = menu({
|
|
before = {
|
|
controls_widget
|
|
},
|
|
items = {
|
|
{ "Move to tag" ,
|
|
move_screentags
|
|
},
|
|
{ "Toggle on tag",
|
|
toggle_screentags
|
|
},
|
|
{ "Stop task",
|
|
function()
|
|
awful.spawn("kill "..tostring(c.pid))
|
|
end
|
|
},
|
|
{ "Kill task",
|
|
function()
|
|
awful.spawn("kill -s KILL "..tostring(c.pid))
|
|
end
|
|
},
|
|
{ "Debug info",
|
|
{
|
|
before = {
|
|
require("widgets.window-debug")()
|
|
}
|
|
}
|
|
}
|
|
},
|
|
vertical = true
|
|
})
|
|
|
|
return function(c)
|
|
local buttons = gears.table.join(
|
|
awful.button({ }, 1, function()
|
|
c:emit_signal("request::activate", "titlebar", {raise = true})
|
|
awful.mouse.client.move(c)
|
|
end),
|
|
awful.button({ }, 3, function()
|
|
c:emit_signal("request::activate", "titlebar", {raise = true})
|
|
awful.mouse.client.resize(c)
|
|
end)
|
|
)
|
|
c.menu_button = awful.titlebar.widget.iconwidget(c)
|
|
-- A little trick we do to conserve memory and cpu usage on regenerating
|
|
-- buttons is we pop up a menu in the location of the icon
|
|
-- and insert buttons into the controls widget layout.
|
|
c.hidden_floatingbutton = awful.titlebar.widget.floatingbutton(c)
|
|
c.hidden_stickybutton = awful.titlebar.widget.stickybutton(c)
|
|
c.hidden_ontopbutton = awful.titlebar.widget.ontopbutton(c)
|
|
c.menu_button:connect_signal("button::press", function()
|
|
menu_widget.toggle()
|
|
if controls_widget then
|
|
controls_widget:reset()
|
|
controls_widget:add(c.hidden_floatingbutton)
|
|
controls_widget:add(c.hidden_stickybutton)
|
|
controls_widget:add(c.hidden_ontopbutton)
|
|
end
|
|
c:emit_signal("request::activate", "titlebar", {raise = true})
|
|
end)
|
|
c:connect_signal("unfocus",function()
|
|
if menu_widget.visible then
|
|
menu_widget.toggle(0,0)
|
|
end
|
|
end)
|
|
return awful.titlebar(c) : setup {
|
|
{ -- Left
|
|
c.menu_button,
|
|
layout = wibox.layout.fixed.horizontal
|
|
},
|
|
{ -- Middle
|
|
awful.titlebar.widget.titlewidget(c),
|
|
buttons = buttons,
|
|
layout = wibox.layout.flex.horizontal
|
|
},
|
|
{ -- Right
|
|
{
|
|
{
|
|
awful.titlebar.widget.maximizedbutton(c),
|
|
awful.titlebar.widget.minimizebutton (c),
|
|
awful.titlebar.widget.closebutton (c),
|
|
layout = wibox.layout.fixed.horizontal(),
|
|
widget = wibox.container.margin,
|
|
margins = 3
|
|
},
|
|
widget = wibox.container.background,
|
|
shape = gears.shape.rounded_bar,
|
|
bg = {
|
|
type = "linear",
|
|
from = { 0, 15 },
|
|
to = { 0, 0},
|
|
stops = { { 0, "#5d5d5955"} , {1, "39383555"} }
|
|
},
|
|
},
|
|
widget = wibox.container.margin,
|
|
margins = 2
|
|
},
|
|
spacing = 10,
|
|
layout = wibox.layout.align.horizontal,
|
|
}
|
|
end
|