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.

136 lines
6.0 KiB

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. -- awful.widget.tasklist but it can change geometry based on "vertical" property
  9. local awful = require("awful")
  10. local wibox = require("wibox")
  11. local gears = require("gears")
  12. local awmtk2 = require("awmtk2")
  13. local tasklist_buttons = gears.table.join(
  14. awful.button({}, 1, function(c)
  15. if c == client.focus then
  16. c.minimized = true
  17. else
  18. c:emit_signal(
  19. "request::activate",
  20. "tasklist",
  21. {raise = true}
  22. )
  23. end
  24. end),
  25. awful.button({}, 4, function()
  26. awful.client.focus.byidx(1)
  27. end),
  28. awful.button({}, 5, function()
  29. awful.client.focus.byidx(-1)
  30. end)
  31. )
  32. return function(args)
  33. local style = awmtk2.create_style("tasklist",
  34. awmtk2.generic.oneline_widget, args.style)
  35. local templates = awmtk2.create_template_lib("tasklist", awmtk2.templates, args.templates)
  36. local t = awmtk2.build_templates(templates,style,args.vertical)
  37. local button = t.button({
  38. {
  39. {
  40. id = "clienticon",
  41. widget = awful.widget.clienticon
  42. },
  43. (not args.vertical) and t.textbox({
  44. id = "text_role"
  45. }),
  46. layout = wibox.layout.fixed.horizontal,
  47. spacing = style.button.spacing
  48. },
  49. widget = wibox.container.constraint,
  50. strategy="exact",
  51. width = style.button.width,
  52. height = style.button.height,
  53. id = "constraint_task"
  54. },{
  55. create_callback = function(self, c, index, objects)
  56. self:get_children_by_id('clienticon')[1].client = c
  57. -- If for some ungodly reason you enabled the behaviour of the original awesomewm, this script will just stop after setting the client icon.
  58. if self.id == "background_role" then
  59. return
  60. end
  61. local textbox = self:get_children_by_id("text_role")[1] or {}
  62. -- Apparently the original system for changing bgimage is
  63. -- 1) broken
  64. -- 2) uses deprecated functions (nice code practices awesomewm)
  65. -- Solution: write my own. I blame material design for all this.
  66. -- (P.S: Not to bullshit you, check it yourself - replicatable
  67. -- by adding theme.tasklist_bg_image_normal or
  68. -- theme.tasklist_bg_image_focus in current beautiful theme.)
  69. local onfocus = function()
  70. self.bgimage = style.button.bgimage_focus
  71. self.bg = style.button.bg_focus
  72. self.shape = style.button.shape_focus
  73. self.shape_border_width = style.button.shape_border_width_focus
  74. self.shape_border_color = style.button.shape_border_color_focus
  75. textbox.font = style.textbox.font_focus
  76. end
  77. local onunfocus = function()
  78. self.bgimage = style.button.bgimage_normal
  79. self.bg = style.button.bg_normal
  80. self.shape = style.button.shape_normal
  81. self.shape_border_width = style.button.shape_border_width_normal
  82. self.shape_border_color = style.button.shape_border_color_normal
  83. textbox.font = style.textbox.font_normal
  84. end
  85. local onurgent = function()
  86. if not c.urgent then return end
  87. self.bgimage = style.button.bgimage_urgent
  88. self.bg = style.button.bg_urgent
  89. self.shape = style.button.shape_urgent
  90. self.shape_border_width = style.button.shape_border_width_urgent
  91. self.shape_border_color = style.button.shape_border_color_urgent
  92. textbox.font = style.textbox.font_urgent
  93. end
  94. local onminimize = function()
  95. if not c.minimized then return end
  96. self.bgimage = style.button.bgimage_minimize
  97. self.bg = style.button.bg_minimize
  98. self.shape = style.button.shape_minimize
  99. self.shape_border_width = style.button.shape_border_width_minimize
  100. self.shape_border_color = style.button.shape_border_color_minimize
  101. textbox.font = style.textbox.font_minimize
  102. end
  103. c:connect_signal("focus",onfocus)
  104. c:connect_signal("unfocus",onunfocus)
  105. c:connect_signal("property::urgent",onurgent)
  106. c:connect_signal("property::minimized",onminimize)
  107. if client.focus == c then
  108. onfocus()
  109. else
  110. onunfocus()
  111. end
  112. end,
  113. -- Uncomment this only, and **ONLY** if you actually need it.
  114. --id = "background_role"
  115. })
  116. return awful.widget.tasklist {
  117. screen = args.screen,
  118. filter = awful.widget.tasklist.filter.currenttags,
  119. buttons = tasklist_buttons,
  120. layout = {
  121. -- basically we just map every property of this to beautiful.tasklist.base
  122. spacing = style.base.spacing,
  123. spacing_widget = style.base.spacing_widget,
  124. -- Now THIS is shit racing
  125. layout = (
  126. (args.vertical and style.base.layout_vertical) or
  127. style.base.layout_horizontal
  128. ) or (
  129. (args.vertical and wibox.layout.fixed.vertical) or
  130. wibox.layout.fixed.horizontal
  131. )
  132. },
  133. widget_template = button
  134. }
  135. end