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.

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