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

2 years ago
2 years ago
2 years ago
  1. -- This file is part of Reno desktop.
  2. --
  3. -- 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.
  4. --
  5. -- 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.
  6. --
  7. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
  8. -- Start button that summons the root menu or any other menu if needed
  9. local awmtk2 = require("awmtk2")
  10. local wibox = require("wibox")
  11. local gears = require("gears")
  12. local awful = require("awful")
  13. local beautiful = require("beautiful")
  14. local builder = require("builder")
  15. return function(args)
  16. local popup
  17. do
  18. local style = awmtk2.create_style("startbutton",
  19. awmtk2.generic.popup,args.style)
  20. local templates = awmtk2.create_template_lib("startbutton",awmtk2.templates,args.templates)
  21. local t = awmtk2.build_templates(templates,style,args.vertical)
  22. local config_file = io.open(root_path.."/themes/"..global.theme.."/config/startbutton.lua","r")
  23. local config
  24. if config_file then
  25. config = config_file:read("*a")
  26. config_file:close()
  27. else
  28. config = [[{"list": [{"widget": "widgets.base.popuptitle","options":{"vertical":true}},{"widget":"widgets.start.xdgmenu"}]}]]
  29. end
  30. popup = awful.popup(t.popup({
  31. markup = "brainhurt 2",
  32. widget = wibox.widget.textbox
  33. }))
  34. popup.widget = wibox.widget(t.popup(builder(
  35. config,
  36. {
  37. style = style.base,
  38. screen = mouse.screen,
  39. passthrough = {
  40. parent = popup
  41. }
  42. }
  43. )).widget)
  44. for _,layout in pairs(popup.widget:get_children_by_id("menu_root")) do
  45. for _,button in pairs(layout.children) do
  46. button:connect_signal("cascade::kill",function()
  47. popup.visible = false
  48. end)
  49. end
  50. end
  51. popup:connect_signal("property::visible",function()
  52. local roots = popup.widget:get_children_by_id("menu_root")
  53. for k,v in pairs(roots) do
  54. for _,w in ipairs(v.children) do
  55. w:emit_signal("cascade::close")
  56. end
  57. end
  58. end)
  59. end
  60. local style = awmtk2.create_style("startbutton",
  61. awmtk2.generic.iconified_widget,args.style)
  62. local templates = awmtk2.create_template_lib("startbutton",awmtk2.templates,args.templates)
  63. local t = awmtk2.build_templates(templates,style,args.vertical)
  64. local widget = wibox.widget(t.button(t.article({
  65. icon = style.article.icon,
  66. title = style.article.title or "Start"
  67. })))
  68. widget:connect_signal("button::press",style.button.onpress)
  69. widget:connect_signal("button::release",style.button.onrelease)
  70. widget:connect_signal("button::press",function()
  71. popup.visible = (not popup.visible)
  72. if popup.visible then
  73. local _, corner = awful.placement.closest_corner(
  74. mouse,
  75. {parent = mouse.screen,pretend = true}
  76. )
  77. if corner then
  78. (awful.placement[corner]+
  79. awful.placement.no_offscreen+
  80. awful.placement.no_overlap) (
  81. popup,
  82. {parent = mouse.screen}
  83. )
  84. end
  85. end
  86. end)
  87. return widget
  88. end