Compare commits

..

No commits in common. "39ca509391c4fd256dbe178232981d31db7c82c0" and "09c204ae2db91a4cf7223ee2bda07b1b6f6d545d" have entirely different histories.

7 changed files with 141 additions and 97 deletions

View File

@ -3,7 +3,7 @@
terminal = "$HOME/.local/bin/st" terminal = "$HOME/.local/bin/st"
browser = "prime-run librewolf" browser = "prime-run librewolf"
modkey = "Mod4" modkey = "Mod4"
theme = "unity" theme = "serenity"
shell = "zsh" shell = "zsh"
# Keybindings # Keybindings

View File

@ -37,7 +37,7 @@ end
return function(args) return function(args)
-- A way to communicate that all widgets in menu got closed -- A way to communicate that all widgets in menu got closed
args.on_close = args.on_close or function() end args.on_close = args.on_close or function() end
local style = awmtk2.create_style("menu", local style = awmtk2.create_style("menu",
awmtk2.generic.menu, args.style) awmtk2.generic.menu, args.style)
local templates = awmtk2.create_template_lib("menu", awmtk2.templates, args.templates) local templates = awmtk2.create_template_lib("menu", awmtk2.templates, args.templates)
local t = awmtk2.build_templates(templates,style) local t = awmtk2.build_templates(templates,style)
@ -53,14 +53,13 @@ return function(args)
local onpress = function(widget) local onpress = function(widget)
style.button.onrelease(widget) style.button.onrelease(widget)
widget:emit_signal("cascade::kill") widget:emit_signal("cascade::kill")
if root_layer._private.focused then if root_layer.focused then
root_layer._private.focused:emit_signal("cascade::kill") root_layer.focused:emit_signal("cascade::kill")
root_layer:emit_signal("cascade::kill")
end end
end end
if type(element[2]) == "string" then if type(element[2]) == "string" then
new_element:connect_signal("button::press",style.button.onpress) new_element:connect_signal("button::press",style.button.onpress)
new_element:connect_signal("button::press",function() new_element:connect_signal("button::press",function(widget)
awful.spawn(element[2]) awful.spawn(element[2])
end) end)
new_element:connect_signal("button::release",onpress) new_element:connect_signal("button::release",onpress)
@ -69,12 +68,12 @@ return function(args)
new_element:connect_signal("button::press",element[2]) new_element:connect_signal("button::press",element[2])
new_element:connect_signal("button::release",onpress) new_element:connect_signal("button::release",onpress)
elseif type(element[2]) == "table" then elseif type(element[2]) == "table" then
local layout = wibox.widget({ local layout = {
spacing = style.base.spacing, spacing = style.base.spacing,
layout = wibox.layout.fixed.vertical layout = wibox.layout.fixed.vertical
}) }
for _,v in pairs(element[2]) do for k,v in pairs(element[2]) do
layout:add(menu_builder(v,layout,root_layer)) table.insert(layout,menu_builder(v,layout,root_layer))
end end
local next_layer = awful.popup(t.popup(layout,{ local next_layer = awful.popup(t.popup(layout,{
visible = false, visible = false,
@ -83,31 +82,29 @@ return function(args)
preferred_anchors = {"front","back"}, preferred_anchors = {"front","back"},
})) }))
local function open_layer(widget) local function open_layer(widget)
if layer._private.focused == widget and if layer.focused == widget and
next_layer.visible then next_layer.visible then
return return
end end
if layer._private.focused then if layer.focused then
layer._private.focused:emit_signal("cascade::close") layer.focused:emit_signal("cascade::close")
end end
layer._private.focused = widget layer.focused = widget
position_popup(next_layer, new_element, style) position_popup(next_layer, new_element, style)
end end
local onclose = function() local onclose = function()
style.button.onrelease(new_element) style.button.onrelease(new_element)
if layout._private.focused then if layout.focused then
layout._private.focused:emit_signal("cascade::close") layout.focused:emit_signal("cascade::close")
end end
next_layer.visible = false next_layer.visible = false
end end
new_element:connect_signal("cascade::close",onclose) new_element:connect_signal("cascade::close",onclose)
new_element:connect_signal("cascade::kill",onclose) new_element:connect_signal("cascade::kill",onclose)
root_layer:connect_signal("cascade::kill",onclose)
root_layer:connect_signal("cascade::close",onclose)
-- that sweet "just move the mouse 4head" navigation -- that sweet "just move the mouse 4head" navigation
if style.base.menu_slide then if style.base.menu_slide then
new_element:connect_signal("mouse::enter",open_layer) new_element:connect_signal("mouse::enter",open_layer)
new_element:connect_signal("mouse::enter",style.button.onpress) new_element:connect_signal("mouse::enter",style.button.onpress)
else else
new_element:connect_signal("button::press",style.button.onpress) new_element:connect_signal("button::press",style.button.onpress)
new_element:connect_signal("button::press",open_layer) new_element:connect_signal("button::press",open_layer)
@ -115,13 +112,13 @@ return function(args)
end end
return new_element return new_element
end end
local root_layer = args.parent or wibox.widget { local root_layer = {
layout = wibox.layout.fixed.vertical, layout = wibox.layout.fixed.vertical,
id = "menu_root", id = "menu_root",
spacing = style.base.spacing spacing = style.base.spacing
} }
for _,v in pairs(args.items) do for k,v in pairs(args.items) do
root_layer:add(menu_builder(v,root_layer,root_layer)) table.insert(root_layer,menu_builder(v,root_layer,root_layer))
end end
return root_layer return root_layer
end end

View File

@ -11,56 +11,54 @@ local wibox = require("wibox")
local awful = require("awful") local awful = require("awful")
local gears = require("gears") local gears = require("gears")
local builder = require("builder") local builder = require("builder")
local menugen = require("context_menu")
local ask = require("asckey") local ask = require("asckey")
local style = awmtk2.create_style("client_menu", local style = awmtk2.create_style("client_menu",
awmtk2.generic.composite_widget,{}) awmtk2.generic.composite_widget,{})
local templates = awmtk2.create_template_lib("client_menu",awmtk2.templates,{}) local templates = awmtk2.create_template_lib("client_menu",awmtk2.templates,{})
local t = awmtk2.build_templates(templates,style,false) local t = awmtk2.build_templates(templates,style,false)
-- Create a global context menu for clients first -- Create a global context menu for clients first
-- This saves us memory on not creating separate menus for every client -- This saves us memory on not creating separate menus for every client
if not context_menu then if not context_menu then
-- load client menu config local config_file = io.open(root_path.."/themes/"..global.theme..'/config/client_menu.json',"r")
local config_file = io.open(root_path.."/themes/"..global.theme..'/config/client_menu.json',"r") local config
local config if config_file then
if config_file then config = config_file:read("*a")
config = config_file:read("*a") config_file:close()
config_file:close() else
else config = [[{"list":[{"widget":"widgets.clientcontrols"}]}]]
config = [[{"list":[{"widget":"widgets.clientcontrols"}]}]] end
context_menu = awful.popup(t.popup(builder(
config,
{
style = style.base,
}
)))
context_menu:connect_signal("button::press",function(self,x,y,b)
if b == 3 then
context_menu.visible = false
end end
-- NOTE: Please attach your menus to the prime_menu. It should be available as args.menu_parent via passthrough end)
local prime_menu = menugen({items={}}) context_menu:connect_signal("property::visible",function(self,x,y,b)
context_menu = awful.popup(t.popup(builder( if not context_menu.visible then
config, local children = context_menu.widget:get_children_by_id("menu_root")
{ for k,v in pairs(children) do
style = style.base, for k2,v2 in pairs(v.children) do
passthrough = { v2:emit_signal("cascade::close")
menu_parent = prime_menu end
} end
} end
))) end)
-- Close context menu on right click client.connect_signal("focus",function()
context_menu:connect_signal("button::press",function(_,_,_,b) context_menu.visible = false
if b == 3 then end)
for _,layout in pairs(context_menu.widget:get_children_by_id("menu_root")) do
for _,button in pairs(layout.children) do
button:connect_signal("cascade::kill",function()
context_menu.visible = false context_menu.visible = false
end end)
end) end
-- Close all cascading menus if our menu becomes invisible end
context_menu:connect_signal("property::visible",function()
if not context_menu.visible then
prime_menu:emit_signal("cascade::close")
end
end)
-- If client became unfocused, close menu
client.connect_signal("focus",function()
context_menu.visible = false
end)
-- Close our context menu when any of the attached menus signal cascade::kill
prime_menu:connect_signal("cascade::kill",function()
context_menu.visible = false
end)
end end
root.keys(gears.table.join( root.keys(gears.table.join(
root.keys(), root.keys(),

View File

@ -6,18 +6,23 @@
-- --
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>. -- 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 -- Basic client control menu
local awmtk2 = require("awmtk2")
local awful = require("awful") local awful = require("awful")
local menugen = require("context_menu") local menugen = require("context_menu")
return function(args) return function(args)
local style = awmtk2.create_style("client_controls",
awmtk2.generic.menu,args.style,args.vertical)
local templates = awmtk2.create_template_lib("client_controls",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style,args.vertical)
local move_to_tag = {} local move_to_tag = {}
local add_to_tag = {} local add_to_tag = {}
awful.screen.connect_for_each_screen(function(s) awful.screen.connect_for_each_screen(function(s)
table.insert(move_to_tag,{ table.insert(move_to_tag,{
"Screen "..s.index, "Screen "..s.index,
(function() (function()
local t = {} local t = {}
for _,v in pairs(s.tags) do for k,v in pairs(s.tags) do
table.insert(t,{v.name,function() table.insert(t,{v.name,function()
if client.focus then if client.focus then
client.focus:tags({v}) client.focus:tags({v})
@ -29,9 +34,9 @@ return function(args)
}) })
table.insert(add_to_tag,{ table.insert(add_to_tag,{
"Screen "..s.index, "Screen "..s.index,
(function() (function()
local t = {} local t = {}
for _,v in pairs(s.tags) do for k,v in pairs(s.tags) do
table.insert(t,{v.name,function() table.insert(t,{v.name,function()
if client.focus then if client.focus then
local tags = client.focus:tags() local tags = client.focus:tags()
@ -60,7 +65,6 @@ return function(args)
{ "Move to tag", move_to_tag }, { "Move to tag", move_to_tag },
{ "Switch on tag", add_to_tag } { "Switch on tag", add_to_tag }
}, },
parent = args.menu_parent
}) })
return widget return widget
end end

View File

@ -10,7 +10,7 @@ local awmtk2 = require("awmtk2")
local wibox = require("wibox") local wibox = require("wibox")
local gears = require("gears") local gears = require("gears")
local awful = require("awful") local awful = require("awful")
local menugen = require("context_menu") local beautiful = require("beautiful")
local builder = require("builder") local builder = require("builder")
return function(args) return function(args)
@ -18,54 +18,49 @@ return function(args)
awmtk2.generic.composite_widget,{}) awmtk2.generic.composite_widget,{})
local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{}) local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{})
local t = awmtk2.build_templates(templates,style,args.vertical) local t = awmtk2.build_templates(templates,style,args.vertical)
-- Layout configuration
local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r") local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r")
local config local config
if config_file then if config_file then
config = config_file:read("*a") config = config_file:read("*a")
config_file:close() config_file:close()
else else
config = [[{"list": [{"widget": "widgets.rootcontrols"}],"vertical": true}]] config = [[{"list": [{"widget": "widgets.rootcontrols"}],"vertical": true}]]
end end
-- NOTE: **PLEASE** attach your other menus to this thing, ok? IF YOU DON'T, THE MENUS WILL WORK LIKE SHIT -- TODO: Refactor this whole mess
-- NOTE 2: THERE IS NO OTHER "PROPER" FIX FOR THIS, JUST LOOK AT THE PREVIOUS SYSTEM (SPOILER: it was ABSOLUTE GARBAGE)
-- Primary menu to which other menus get attached
local prime_menu = menugen({items = {}})
-- Not yet loaded menu popup (TODO: maybe make it more obvious that it's a global?)
root_menu = awful.popup(t.popup({ root_menu = awful.popup(t.popup({
markup = "brainhurt the game", markup = "brainhurt the game",
prime_menu,
widget = wibox.widget.textbox widget = wibox.widget.textbox
})) }))
-- Close popup on right click root_menu:connect_signal("button::press",function(self,x,y,b)
root_menu:connect_signal("button::press",function(_,_,_,b)
if b == 3 then if b == 3 then
root_menu.visible = false root_menu.visible = false
end end
end) end)
-- Build the menu based on the json config
root_menu.widget = wibox.widget(t.popup(builder( root_menu.widget = wibox.widget(t.popup(builder(
config, config,
{ {
style = style.base, style = style.base,
screen = mouse.screen, screen = mouse.screen,
passthrough = { passthrough = {
-- This is the menu to which other menus should attach (available as args.menu_parent) parent = root_menu
menu_parent = prime_menu,
} }
} }
)).widget) )).widget)
-- Close the menu if prime_menu received a cascade::kill signal for _,layout in pairs(root_menu.widget:get_children_by_id("menu_root")) do
prime_menu:connect_signal("cascade::kill",function() for _,button in pairs(layout.children) do
root_menu.visible = false button:connect_signal("cascade::kill",function()
end) root_menu.visible = false
-- Close the prime_menu if our menu becomes invisible end)
end
end
root_menu:connect_signal("property::visible",function() root_menu:connect_signal("property::visible",function()
if not root_menu.visible then local roots = root_menu.widget:get_children_by_id("menu_root")
prime_menu:emit_signal_recursive("cascade::close") for k,v in pairs(roots) do
for _,w in ipairs(v.children) do
w:emit_signal("cascade::close")
end
end end
end) end)
-- Make the root_menu pop up on the desktop on right click
local buttons = root.buttons() local buttons = root.buttons()
root.buttons(gears.table.join(buttons, root.buttons(gears.table.join(buttons,
awful.button({}, 3, function() awful.button({}, 3, function()
@ -79,4 +74,4 @@ return function(args)
end) end)
)) ))
return root_menu return root_menu
end end

View File

@ -6,10 +6,18 @@
-- --
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
-- Simple global context menu controls -- Simple global context menu controls
local awmtk2 = require("awmtk2")
local wibox = require("wibox")
local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local menugen = require("context_menu") local menugen = require("context_menu")
return function(args) return function(args)
local style = awmtk2.create_style("root_menu",
awmtk2.generic.menu,args.style,args.vertical)
local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,args.templates)
local t = awmtk2.build_templates(templates,style,args.vertical)
local widget = menugen({ local widget = menugen({
items = { items = {
{"Awesome", { {"Awesome", {
@ -20,7 +28,6 @@ return function(args)
}, beautiful.awesome_icon}, }, beautiful.awesome_icon},
{"open terminal", global.terminal}, {"open terminal", global.terminal},
}, },
parent = args.menu_parent
}) })
return widget return widget
end end

View File

@ -43,7 +43,9 @@ return function(args)
end end
return false return false
end end
awesome.connect_signal("xdg::all_finished",function() awesome.connect_signal("xdg::all_finished",function()
if not args.parent then return end
local items = {} local items = {}
for k,v in pairs(xdg.categories) do for k,v in pairs(xdg.categories) do
local noprocess = false local noprocess = false
@ -69,10 +71,51 @@ return function(args)
-- uhhh there's a lot of things about async, some of which i can't explain -- uhhh there's a lot of things about async, some of which i can't explain
local xdg_menu_root = widget:get_children_by_id("xdg_menu_root")[1] local xdg_menu_root = widget:get_children_by_id("xdg_menu_root")[1]
xdg_menu_root:reset() xdg_menu_root:reset()
menugen({ local menu = wibox.widget(menugen({
items = items, items = items,
parent = args.menu_parent }))
}) local menu_root = menu:get_children_by_id("menu_root")[1]
for _,v in pairs(menu_root.children) do
v:connect_signal("cascade::kill",function()
args.parent.visible = false
end)
args.parent:connect_signal("property::visible",function()
if not args.parent.visible then
v:emit_signal("cascade::close")
end
end)
menu:connect_signal("widget::redraw_needed",function()
if not menu.visible then
v:emit_signal("cascade::close")
end
end)
end
local appswitch = wibox.widget(t.button(t.textbox({
markup = "Applications",
id = "apptext"
}),{
forced_height = style.button.forced_height,
forced_width = style.button.forced_width
}))
appswitch:connect_signal("button::press",function(self)
menu.visible = (not menu.visible)
if not menu.visible then
xdg_menu_root.spacing = 0
else
xdg_menu_root.spacing = style.base.spacing
end
local textbox = appswitch:get_children_by_id("apptext")[1]
if menu.visible then
style.button.onpress(self)
textbox:set_markup("<b>Applications</b>")
else
style.button.onrelease(self)
textbox:set_markup("Applications")
end
end)
menu.visible = false
xdg_menu_root:add(appswitch)
xdg_menu_root:add(menu)
end) end)
return widget return widget
end end