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.

71 lines
2.3 KiB

2 years ago
2 years ago
2 years ago
  1. local awmtk2 = require("awmtk2")
  2. local wibox = require("wibox")
  3. local gears = require("gears")
  4. local awful = require("awful")
  5. local beautiful = require("beautiful")
  6. local builder = require("builder")
  7. return function(args)
  8. local style = awmtk2.create_style("root_menu",awmtk2.default,{})
  9. local templates = awmtk2.create_template_lib("root_menu",awmtk2.templates,{})
  10. local t = awmtk2.build_templates(templates,style)
  11. local config_file = io.open(root_path.."/themes/"..global.theme.."/config/root_menu.json","r")
  12. local config
  13. if config_file then
  14. config = config_file:read("*a")
  15. config_file:close()
  16. else
  17. config = [[{"list": [{"widget": "widgets.rootcontrols"}],"vertical": true}]]
  18. end
  19. -- TODO: Refactor this whole mess
  20. root_menu = awful.popup(t.popup({
  21. markup = "brainhurt the game",
  22. widget = wibox.widget.textbox
  23. }))
  24. root_menu:connect_signal("button::press",function(self,x,y,b)
  25. if b == 3 then
  26. root_menu.visible = false
  27. end
  28. end)
  29. root_menu._menu_private = {}
  30. root_menu.widget = wibox.widget(t.popup(builder(
  31. config,
  32. {
  33. style = style.base,
  34. screen = mouse.screen,
  35. passthrough = {
  36. parent = root_menu,
  37. _tracking_layer = root_menu._menu_private
  38. }
  39. }
  40. )).widget)
  41. for _,layout in pairs(root_menu.widget:get_children_by_id("menu_root")) do
  42. print(layout)
  43. for _,button in pairs(layout.children) do
  44. button:connect_signal("cascade::kill",function()
  45. root_menu.visible = false
  46. end)
  47. end
  48. end
  49. root_menu:connect_signal("property::visible",function()
  50. local roots = root_menu.widget:get_children_by_id("menu_root")
  51. for k,v in pairs(roots) do
  52. for _,w in ipairs(v.children) do
  53. w:emit_signal("cascade::close")
  54. end
  55. end
  56. end)
  57. local buttons = root.buttons()
  58. root.buttons(gears.table.join(buttons,
  59. awful.button({}, 3, function()
  60. root_menu.visible = (not root_menu.visible)
  61. if root_menu.visible then
  62. root_menu:move_next_to(gears.table.join(mouse.coords(),{
  63. width = 0,
  64. height = 0
  65. }))
  66. end
  67. end)
  68. ))
  69. return root_menu
  70. end