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.

149 lines
5.5 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
  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 -- {{{ Titlebars
  46. local titlebar_config = {}
  47. local style = awmtk2.create_style("titlebar",awmtk2.default,{})
  48. for k,v in pairs({"titlebar_top","titlebar_left","titlebar_right","titlebar_bottom"}) do
  49. -- Create styles for each titlebar
  50. style[v] = awmtk2.create_delta(v, {},
  51. (beautiful.widgets and beautiful.widgets.titlebar) or {},
  52. style.titlebar)
  53. -- Load in json layouts for titlebars
  54. titlebar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
  55. end
  56. local templates = awmtk2.create_template_lib("titlebar",awmtk2.templates,{})
  57. local t = awmtk2.build_templates(templates,style)
  58. -- Add titlebars to normal windows
  59. table.insert(awful.rules.rules,
  60. { rule_any = {type = { "normal", "dialog" }
  61. }, properties = { titlebars_enabled = true }
  62. }
  63. )
  64. client.connect_signal("request::titlebars",function(c)
  65. local buttons = gears.table.join(
  66. awful.button({}, 1, function()
  67. c:emit_signal("request::activate","titlebar",{raise=true})
  68. awful.mouse.client.move(c)
  69. end),
  70. awful.button({}, 3, function()
  71. c:emit_signal("request::activate","titlebar",{raise=true})
  72. awful.mouse.client.resize(c)
  73. end)
  74. )
  75. for k,v in pairs({"titlebar_top","titlebar_bottom","titlebar_left","titlebar_right"}) do
  76. local contents = { widget = wibox.container.background }
  77. if titlebar_config[v] then
  78. contents = builder(titlebar_config[v],{
  79. client = c,
  80. screen = c.screen,
  81. style = style[v],
  82. buttons = buttons
  83. })
  84. end
  85. awful.titlebar(c,{
  86. size = style[v].size or 0,
  87. position = v:gsub("titlebar_",""),
  88. bg_normal = style[v].bg_normal,
  89. bg_focus = style[v].bg_focus,
  90. bgimage_normal = style[v].bgimage_normal,
  91. bgimage_focus = style[v].bgimage_focus,
  92. fg_normal = style[v].fg_normal,
  93. fg_focus = style[v].fg_focus,
  94. font = style[v].font
  95. }):setup(t.titlebar(contents))
  96. end
  97. end)
  98. end --}}}
  99. do --{{{ Screen
  100. local wibar_config = {}
  101. local style = awmtk2.create_style("wibar",awmtk2.default,{})
  102. for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
  103. style[v] = awmtk2.create_delta(v, {},
  104. (beautiful.widgets and beautiful.widgets.wibar) or {},
  105. style.wibar)
  106. wibar_config[v] = read_file(root_path.."/themes/"..global.theme.."/config/"..v..".json")
  107. end
  108. local templates = awmtk2.create_template_lib("wibar",awmtk2.templates,{})
  109. local t = awmtk2.build_templates(templates,style)
  110. awful.screen.connect_for_each_screen(function(s)
  111. for k,v in pairs({"wibar_top","wibar_bottom","wibar_left","wibar_right"}) do
  112. local contents = { widget = wibox.container.background }
  113. if wibar_config[v] then
  114. contents = builder(wibar_config[v],{
  115. client = c,
  116. style = style[v],
  117. buttons = buttons,
  118. screen = s
  119. })
  120. s[v] = awful.wibar({
  121. -- There really isn't a better way to do this. I wish there was.
  122. position = v:gsub("wibar_",""),
  123. screen = s,
  124. visible = true,
  125. stretch = style[v].stretch,
  126. ontop = style[v].ontop,
  127. width = style[v].width,
  128. height = style[v].height,
  129. border_width = style[v].border_width,
  130. border_color = style[v].border_color,
  131. opacity = style[v].opacity or 1,
  132. shape = style[v].shape,
  133. bg = style[v].bg,
  134. bgimage = style[v].bgimage,
  135. fg = style[v].fg,
  136. input_passthrough = style[v].input_passthrough
  137. })
  138. s[v]:setup(t.wibar(contents))
  139. end
  140. end
  141. end)
  142. end -- }}}