Reno is the second iteration of the AWMTK-powered AwesomeWM config.
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.
 
 
 
 

89 lines
3.7 KiB

-- 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/>.
-- Start button that summons the root menu or any other menu if needed
local awmtk2 = require("awmtk2")
local wibox = require("wibox")
local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful")
local builder = require("builder")
return function(args)
local popup
do
local style = awmtk2.create_style("startbutton",
awmtk2.generic.popup,args.style)
local templates = awmtk2.create_template_lib("startbutton",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style,args.vertical)
local config_file = io.open(root_path.."/themes/"..global.theme.."/config/startbutton.lua","r")
local config
if config_file then
config = config_file:read("*a")
config_file:close()
else
config = [[{"list": [{"widget": "widgets.base.popuptitle","options":{"vertical":true}},{"widget":"widgets.start.xdgmenu"}]}]]
end
popup = awful.popup(t.popup({
markup = "brainhurt 2",
widget = wibox.widget.textbox
}))
popup.widget = wibox.widget(t.popup(builder(
config,
{
style = style.base,
screen = mouse.screen,
passthrough = {
parent = popup
}
}
)).widget)
for _,layout in pairs(popup.widget:get_children_by_id("menu_root")) do
for _,button in pairs(layout.children) do
button:connect_signal("cascade::kill",function()
popup.visible = false
end)
end
end
popup:connect_signal("property::visible",function()
local roots = popup.widget:get_children_by_id("menu_root")
for k,v in pairs(roots) do
for _,w in ipairs(v.children) do
w:emit_signal("cascade::close")
end
end
end)
end
local style = awmtk2.create_style("startbutton",
awmtk2.generic.iconified_widget,args.style)
local templates = awmtk2.create_template_lib("startbutton",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style,args.vertical)
local widget = wibox.widget(t.button(t.article({
icon = style.article.icon,
title = style.article.title or "Start"
})))
widget:connect_signal("button::press",style.button.onpress)
widget:connect_signal("button::release",style.button.onrelease)
widget:connect_signal("button::press",function()
popup.visible = (not popup.visible)
if popup.visible then
local _, corner = awful.placement.closest_corner(
mouse,
{parent = mouse.screen,pretend = true}
)
if corner then
(awful.placement[corner]+
awful.placement.no_offscreen+
awful.placement.no_overlap) (
popup,
{parent = mouse.screen}
)
end
end
end)
return widget
end