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.

154 lines
5.7 KiB

1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year 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. local awful = require("awful")
  9. local gears = require("gears")
  10. local awmtk2 = require("awmtk2")
  11. local beautiful = require("beautiful")
  12. local wibox = require("wibox")
  13. local json = require("dkjson")
  14. local try_blur = require("imagemagick_blur")
  15. local ask = require("asckey")
  16. local bgimagegen = function(path)
  17. return function(cont,cr,width,height)
  18. local s = gears.surface.load_uncached_silently(
  19. path
  20. )
  21. local bg_width,bg_height = gears.surface.get_size(s)
  22. local scale = height/bg_height
  23. if width/bg_width > scale then
  24. scale = width/bg_width
  25. end
  26. cr:translate((width - (bg_width*scale))/2,(height - (bg_height*scale))/2)
  27. cr:rectangle(0,0, (bg_width*scale), (bg_height*scale))
  28. cr:clip()
  29. cr:scale(scale,scale)
  30. cr:set_source_surface(s)
  31. cr:paint()
  32. end
  33. end
  34. local function _preload(args)
  35. local style = awmtk2.create_style("supermenu",
  36. awmtk2.generic.composite_widget,{})
  37. local templates = awmtk2.create_template_lib("supermenu",awmtk2.templates,{})
  38. local t = awmtk2.build_templates(templates,style,args.vertical)
  39. local wallpaper
  40. if gears.filesystem.file_readable(root_path.."/wallpaper.txt") then
  41. local wallpaper_f = io.open(root_path.."/wallpaper.txt","r")
  42. wallpaper = wallpaper_f:read("*a")
  43. wallpaper_f:close()
  44. end
  45. supermenu = awful.popup(t.popup({
  46. {
  47. {
  48. widget = wibox.container.background
  49. },
  50. {
  51. layout = wibox.layout.flex.vertical,
  52. id = "contents"
  53. },
  54. {
  55. t.container({
  56. id = "buttonlist",
  57. layout = wibox.layout.fixed.vertical
  58. },{
  59. bg = style.container.bg_highlight
  60. }),
  61. valign = "center",
  62. halign = "right",
  63. fill_vertical = true,
  64. fill_horizontal = false,
  65. widget = wibox.container.place
  66. },
  67. layout = wibox.layout.align.horizontal
  68. },
  69. widget = wibox.container.background,
  70. forced_width = args.screen.workarea.width-style.popup.margins,
  71. forced_height = args.screen.workarea.height-style.popup.margins,
  72. id = "supermenu_root"
  73. },{
  74. x = args.screen.workarea.x,
  75. y = args.screen.workarea.y,
  76. visible = false
  77. }))
  78. local supermenu_root = supermenu.widget:get_children_by_id("supermenu_root")[1]
  79. if style.popup.transparent then
  80. if not awesome.composite_manager_running then
  81. -- Really slow but the effect is ok
  82. supermenu_root.bgimage = bgimagegen(try_blur(wallpaper or beautiful.wallpaper,
  83. function(path)
  84. supermenu_root.bgimage = bgimagegen(path)
  85. end))
  86. else
  87. -- Let the compositor handle transparency
  88. supermenu_root.bg = style.popup.bg_normal.."66"
  89. supermenu.widget.bg = "#00000000"
  90. end
  91. end
  92. args.screen:connect_signal("property::workarea",function()
  93. supermenu.x = args.screen.workarea.x
  94. supermenu.y = args.screen.workarea.y
  95. supermenu_root.forced_width = args.screen.workarea.width-style.popup.margins*2
  96. supermenu_root.forced_height = args.screen.workarea.height-style.popup.margins*2
  97. end)
  98. supermenu:connect_signal("button::press",function(self,x,y,button)
  99. if button == 3 then
  100. supermenu.visible = false
  101. end
  102. end)
  103. local tabsfile = io.open(root_path.."/themes/"..global.theme..'/config/supermenu.json',"r")
  104. local contents = supermenu.widget:get_children_by_id("contents")[1]
  105. local buttonlist = supermenu.widget:get_children_by_id("buttonlist")[1]
  106. local tabs = {}
  107. local tab_icons = {}
  108. local function gen_buttons(tab_id,icon)
  109. local button = wibox.widget({
  110. image = icon,
  111. resize = true,
  112. widget = wibox.widget.imagebox,
  113. forced_width = style.icon.width,
  114. forced_height = style.icon.height
  115. })
  116. button:connect_signal("button::press",function()
  117. contents:set(1,tabs[tab_id])
  118. end)
  119. return button
  120. end
  121. if tabsfile then
  122. for k,v in pairs(json.decode(tabsfile:read("*a"))) do
  123. local widget,icon = require(k)(v)
  124. print(widget,icon)
  125. table.insert(tab_icons,icon or beautiful.icon_default)
  126. table.insert(tabs,widget)
  127. end
  128. end
  129. if tabs[1] then
  130. contents:add(tabs[1])
  131. end
  132. for k,_ in pairs(tabs) do
  133. buttonlist:add(gen_buttons(k,tab_icons[k]))
  134. end
  135. root.keys(gears.table.join(
  136. root.keys(),
  137. ask.k(":supermenu.open",function()
  138. supermenu.visible = not supermenu.visible
  139. end,{
  140. description = "open supermenu",
  141. group = "widgets"
  142. })
  143. ))
  144. return supermenu
  145. end
  146. return function(args)
  147. for s in screen do
  148. s.lock = _preload(gears.table.join(args,{
  149. screen = s
  150. }))
  151. end
  152. end