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.

69 lines
2.1 KiB

2 years ago
  1. -- Base for widgets
  2. local awmtk2 = require("awmtk2")
  3. local wibox = require("wibox")
  4. local gears = require("gears")
  5. local awful = require("awful")
  6. local beautiful = require("beautiful")
  7. local menugen = require("context_menu")
  8. local builder = require("builder")
  9. local style = awmtk2.create_style("client_menu",awmtk2.default,{})
  10. local templates = awmtk2.create_template_lib("client_menu",awmtk2.templates,{})
  11. local t = awmtk2.build_templates(templates,style)
  12. -- Create a global context menu for clients first
  13. if not context_menu then
  14. local config_file = io.open(root_path.."/themes/"..global.theme..'/config/client_menu.json',"r")
  15. local config
  16. if config_file then
  17. config = config_file:read("*a")
  18. config_file:close()
  19. else
  20. config = [[{"list":[{"widget":"widgets.clientcontrols"}]}]]
  21. end
  22. context_menu = awful.popup(t.popup(builder(
  23. config,
  24. {
  25. style = style.base,
  26. }
  27. )))
  28. context_menu:connect_signal("button::press",function(self,x,y,b)
  29. if b == 3 then
  30. context_menu.visible = false
  31. end
  32. end)
  33. context_menu:connect_signal("property::visible",function(self,x,y,b)
  34. if not context_menu.visible then
  35. local children = context_menu.widget:get_children_by_id("menu_root")
  36. for k,v in pairs(children) do
  37. for k2,v2 in pairs(v.children) do
  38. v2:emit_signal("cascade::close")
  39. end
  40. end
  41. end
  42. end)
  43. client.connect_signal("focus",function()
  44. context_menu.visible = false
  45. end)
  46. for _,layout in pairs(context_menu.widget:get_children_by_id("menu_root")) do
  47. for _,button in pairs(layout.children) do
  48. button:connect_signal("cascade::kill",function()
  49. context_menu.visible = false
  50. end)
  51. end
  52. end
  53. end
  54. return function(args)
  55. local widget = wibox.widget({
  56. widget = awful.widget.clienticon,
  57. client = args.client
  58. })
  59. widget:connect_signal("button::press",function()
  60. context_menu.visible = (not context_menu.visible)
  61. if context_menu.visible then
  62. context_menu.x = mouse.coords().x
  63. context_menu.y = mouse.coords().y
  64. end
  65. end)
  66. return widget
  67. end