You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
180 lines
6.0 KiB
180 lines
6.0 KiB
local gears = require("gears")
|
|
local awmtk2 = require("awmtk2")
|
|
local wibox = require("wibox")
|
|
local awful = require("awful")
|
|
local beautiful = require("beautiful")
|
|
local builder = require("builder")
|
|
local mbarutils = require("menubar").utils
|
|
local menugen = require("context_menu")
|
|
|
|
local function read_file(fname)
|
|
local fhandler = io.open(fname,"r")
|
|
if fhandler then
|
|
local data = fhandler:read("*a")
|
|
fhandler:close()
|
|
return data
|
|
end
|
|
end
|
|
|
|
do -- {{{ Root menu
|
|
local style = awmtk2.create_style("root_menu",awmtk2.default,{})
|
|
local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{})
|
|
local t = awmtk2.build_templates(templates,style)
|
|
local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r")
|
|
local config
|
|
if config_file then
|
|
config = config_file:read("*a")
|
|
config_file:close()
|
|
else
|
|
config = [[{"list": [
|
|
{"widget": "widgets.rootmenu"}
|
|
],
|
|
"vertical": true
|
|
}]]
|
|
end
|
|
local root_menu = awful.popup(t.popup(builder(
|
|
config,
|
|
{
|
|
style = style,
|
|
screen = mouse.screen,
|
|
}
|
|
)))
|
|
local buttons = root.buttons()
|
|
root.buttons(gears.table.join(buttons,
|
|
awful.button({}, 3, function()
|
|
if root_menu.visible then
|
|
local roots = root_menu.widget:get_children_by_id("menu_root")
|
|
for k,v in pairs(roots) do
|
|
for _,w in ipairs(v.children) do
|
|
if type(w) == "table" and w.emit_signal then
|
|
w:emit_signal("cascade_close")
|
|
end
|
|
end
|
|
end
|
|
end
|
|
root_menu.visible = (not root_menu.visible)
|
|
if root_menu.visible then
|
|
root_menu:move_next_to(gears.table.join(mouse.coords(),{
|
|
width = 0,
|
|
height = 0
|
|
}))
|
|
end
|
|
end)
|
|
))
|
|
end -- }}}
|
|
|
|
-- {{{ Placeholder Icons
|
|
client.connect_signal("request::titlebars",function(c)
|
|
if (not c.icon) and beautiful.icon_default then
|
|
c.icon = beautiful.icon_default._native
|
|
end
|
|
end)
|
|
-- }}}
|
|
|
|
-- {{{ Global widgets
|
|
local runmenu = require("widgets.dismal")({
|
|
x = 0,
|
|
y = 26
|
|
})
|
|
-- }}}
|
|
|
|
do -- {{{ Titlebars
|
|
local titlebar_config = {}
|
|
local style = awmtk2.create_style("titlebar",awmtk2.default,{})
|
|
for k,v in pairs({"titlebar_top","titlebar_left","titlebar_right","titlebar_bottom"}) do
|
|
-- Create styles for each titlebar
|
|
style[v] = awmtk2.create_delta(v, {},
|
|
(beautiful.widgets and beautiful.widgets.titlebar) or {},
|
|
style.titlebar)
|
|
-- Load in json layouts for titlebars
|
|
titlebar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
|
|
end
|
|
local templates = awmtk2.create_template_lib("titlebar",awmtk2.templates,{})
|
|
local t = awmtk2.build_templates(templates,style)
|
|
-- Add titlebars to normal windows
|
|
table.insert(awful.rules.rules,
|
|
{ rule_any = {type = { "normal", "dialog" }
|
|
}, properties = { titlebars_enabled = true }
|
|
}
|
|
)
|
|
client.connect_signal("request::titlebars",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)
|
|
)
|
|
for k,v in pairs({"titlebar_top","titlebar_bottom","titlebar_left","titlebar_right"}) do
|
|
local contents = { widget = wibox.container.background }
|
|
if titlebar_config[v] then
|
|
contents = builder(titlebar_config[v],{
|
|
client = c,
|
|
screen = c.screen,
|
|
style = style[v],
|
|
buttons = buttons
|
|
})
|
|
end
|
|
awful.titlebar(c,{
|
|
size = style[v].size or 0,
|
|
position = v:gsub("titlebar_",""),
|
|
bg_normal = style[v].bg_normal,
|
|
bg_focus = style[v].bg_focus,
|
|
bgimage_normal = style[v].bgimage_normal,
|
|
bgimage_focus = style[v].bgimage_focus,
|
|
fg_normal = style[v].fg_normal,
|
|
fg_focus = style[v].fg_focus,
|
|
font = style[v].font
|
|
}):setup(t.titlebar(contents))
|
|
end
|
|
end)
|
|
end --}}}
|
|
|
|
do --{{{ Screen
|
|
local wibar_config = {}
|
|
local style = awmtk2.create_style("wibar",awmtk2.default,{})
|
|
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
|
|
style[v] = awmtk2.create_delta(v, {},
|
|
(beautiful.widgets and beautiful.widgets.wibar) or {},
|
|
style.wibar)
|
|
wibar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
|
|
end
|
|
local templates = awmtk2.create_template_lib("wibar",awmtk2.templates,{})
|
|
local t = awmtk2.build_templates(templates,style)
|
|
|
|
awful.screen.connect_for_each_screen(function(s)
|
|
for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
|
|
local contents = { widget = wibox.container.background }
|
|
if wibar_config[v] then
|
|
contents = builder(wibar_config[v],{
|
|
client = c,
|
|
style = style[v],
|
|
buttons = buttons,
|
|
screen = s
|
|
})
|
|
s[v] = awful.wibar({
|
|
-- There really isn't a better way to do this. I wish there was.
|
|
position = v:gsub("wibar_",""),
|
|
screen = s,
|
|
visible = true,
|
|
stretch = style[v].stretch,
|
|
ontop = style[v].ontop,
|
|
width = style[v].width,
|
|
height = style[v].height,
|
|
border_width = style[v].border_width,
|
|
border_color = style[v].border_color,
|
|
opacity = style[v].opacity or 1,
|
|
shape = style[v].shape,
|
|
bg = style[v].bg,
|
|
bgimage = style[v].bgimage,
|
|
fg = style[v].fg,
|
|
input_passthrough = style[v].input_passthrough
|
|
})
|
|
s[v]:setup(t.wibar(contents))
|
|
end
|
|
end
|
|
end)
|
|
end -- }}}
|