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.

180 lines
6.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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. local gears = require("gears")
  9. local awmtk2 = require("awmtk2")
  10. local wibox = require("wibox")
  11. local awful = require("awful")
  12. local beautiful = require("beautiful")
  13. local builder = require("builder")
  14. local mbarutils = require("menubar").utils
  15. local menugen = require("context_menu")
  16. local json = require("dkjson")
  17. local function read_file(fname)
  18. local fhandler = io.open(fname,"r")
  19. if fhandler then
  20. local data = fhandler:read("*a")
  21. fhandler:close()
  22. return data
  23. end
  24. end
  25. -- {{{ Placeholder Icons
  26. client.connect_signal("request::titlebars",function(c)
  27. if (not c.icon) and beautiful.icon_default then
  28. c.icon = beautiful.icon_default._native
  29. end
  30. end)
  31. -- }}}
  32. do -- {{{ Global widgets
  33. local config_file = io.open(root_path.."/themes/"..global.theme.."/config/global.json","r")
  34. local config
  35. if config_file then
  36. config = config_file:read("*a")
  37. config_file:close()
  38. else
  39. config = "[]"
  40. end
  41. for k,v in pairs(json.decode(config) or {}) do
  42. require(k)(v)
  43. end
  44. end -- }}}
  45. do --{{{ Screen
  46. local wibar_config = {}
  47. local style = awmtk2.create_style("wibar",awmtk2.generic.composite_widget,{})
  48. for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
  49. style[v] = awmtk2.create_delta(v, {},
  50. (beautiful.widgets and beautiful.widgets.wibar) or {},
  51. style.wibar)
  52. wibar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
  53. end
  54. local templates = awmtk2.create_template_lib("wibar",awmtk2.templates,{})
  55. local t = awmtk2.build_templates(templates,style)
  56. awful.screen.connect_for_each_screen(function(s)
  57. for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
  58. local contents = { widget = wibox.container.background }
  59. if wibar_config[v] then
  60. contents = builder(wibar_config[v],{
  61. client = c,
  62. style = style[v],
  63. buttons = buttons,
  64. screen = s,
  65. passthrough = {
  66. vertical = ((v == "wibar_left") or
  67. (v == "wibar_right"))
  68. }
  69. })
  70. s[v] = awful.wibar({
  71. -- There really isn't a better way to do this. I wish there was.
  72. position = v:gsub("wibar_",""),
  73. screen = s,
  74. visible = true,
  75. stretch = style[v].stretch,
  76. ontop = style[v].ontop,
  77. width = style[v].width,
  78. height = style[v].height,
  79. border_width = style[v].border_width,
  80. border_color = style[v].border_color,
  81. opacity = style[v].opacity or 1,
  82. shape = style[v].shape,
  83. bg = style[v].bg_normal,
  84. bgimage = style[v].bgimage_normal,
  85. fg = style[v].fg,
  86. input_passthrough = style[v].input_passthrough
  87. })
  88. s[v]:setup(t.wibar(contents))
  89. end
  90. end
  91. end)
  92. end -- }}}
  93. do -- {{{ Titlebars
  94. local titlebar_config = {}
  95. local style = awmtk2.create_style("titlebar",awmtk2.generic.composite_widget,{})
  96. for k,v in pairs({"titlebar_top","titlebar_left","titlebar_right","titlebar_bottom"}) do
  97. -- Create styles for each titlebar
  98. style[v] = awmtk2.create_delta(v, {},
  99. (beautiful.widgets and beautiful.widgets.titlebar) or {},
  100. style.titlebar)
  101. -- Load in json layouts for titlebars
  102. titlebar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
  103. end
  104. local templates = awmtk2.create_template_lib("titlebar",awmtk2.templates,{})
  105. local t = awmtk2.build_templates(templates,style)
  106. -- Add titlebars to normal windows
  107. table.insert(awful.rules.rules,
  108. { rule_any = {type = { "normal", "dialog" }
  109. }, properties = { titlebars_enabled = true }
  110. }
  111. )
  112. client.connect_signal("manage", function(c)
  113. local shape = beautiful.window_shape or function(cr, width, height)
  114. return gears.shape.partially_rounded_rect(cr,width,height,
  115. true,true,false,false,beautiful.window_rounding)
  116. end
  117. c.shape = shape
  118. end)
  119. client.connect_signal("request::titlebars",function(c)
  120. local buttons = gears.table.join(
  121. awful.button({}, 1, function()
  122. c:emit_signal("request::activate","titlebar",{raise=true})
  123. awful.mouse.client.move(c)
  124. end),
  125. awful.button({}, 3, function()
  126. c:emit_signal("request::activate","titlebar",{raise=true})
  127. awful.mouse.client.resize(c)
  128. end)
  129. )
  130. for k,v in pairs({"titlebar_top","titlebar_bottom","titlebar_left","titlebar_right"}) do
  131. local contents = { widget = wibox.container.background }
  132. if titlebar_config[v] then
  133. contents = builder(titlebar_config[v],{
  134. client = c,
  135. screen = c.screen,
  136. style = style[v],
  137. buttons = buttons
  138. })
  139. end
  140. local titlebar = awful.titlebar(c,{
  141. size = style[v].size or 0,
  142. position = v:gsub("titlebar_",""),
  143. bg_normal = style[v].bg_normal,
  144. bg_focus = style[v].bg_focus,
  145. bgimage_normal = style[v].bgimage_normal,
  146. bgimage_focus = style[v].bgimage_focus,
  147. fg_normal = style[v].fg_normal,
  148. fg_focus = style[v].fg_focus,
  149. font = style[v].font
  150. })
  151. c[v] = titlebar:setup(t.titlebar(contents))
  152. awful.rules.rules[1].properties.placement(c)
  153. if style[v].onfocus then
  154. c:connect_signal("focus",function()
  155. style[v].onfocus(titlebar)
  156. end)
  157. end
  158. if style[v].onunfocus then
  159. c:connect_signal("unfocus",function()
  160. style[v].onunfocus(titlebar)
  161. end)
  162. end
  163. c:connect_signal("titlebar::hide",function(c)
  164. c[v].visible = false
  165. end)
  166. c:connect_signal("titlebar::unhide",function(c)
  167. c[v].visible = true
  168. end)
  169. end
  170. end)
  171. end --}}}