my complicated awesomewm config (SUNSETTED)
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.

155 lines
4.8 KiB

  1. local awful = require("awful")
  2. local gears = require("gears")
  3. local wibox = require("wibox")
  4. local menu = require("widgets.polymenu")
  5. local move_screentags = {}
  6. local toggle_screentags = {}
  7. awful.screen.connect_for_each_screen(function(s)
  8. local move_tags = {}
  9. local toggle_tags = {}
  10. for _,tag in pairs(s.tags) do
  11. table.insert(move_tags,{
  12. tag.name,
  13. function()
  14. if client.focus then
  15. client.focus:tags({tag})
  16. end
  17. end
  18. })
  19. table.insert(toggle_tags,{
  20. tag.name,
  21. function()
  22. if client.focus then
  23. local tags = client.focus:tags()
  24. for k,v in pairs(tags) do
  25. if v == tag then
  26. table.remove(tags,k)
  27. client.focus:tags(tags)
  28. return
  29. end
  30. end
  31. table.insert(tags,tag)
  32. client.focus:tags(tags)
  33. end
  34. end
  35. })
  36. end
  37. table.insert(move_screentags,{
  38. "Screen "..tostring(s.index),
  39. move_tags
  40. })
  41. table.insert(toggle_screentags,{
  42. "Screen "..tostring(s.index),
  43. toggle_tags
  44. })
  45. end)
  46. local controls_widget = wibox.widget {
  47. forced_width = 72,
  48. forced_height = 24,
  49. layout = wibox.layout.fixed.horizontal,
  50. }
  51. -- To conserve memory we keep one menu at a time
  52. local menu_widget = menu({
  53. before = {
  54. controls_widget
  55. },
  56. after = {
  57. require("widgets.client-volume")({})
  58. },
  59. items = {
  60. { "Move to tag" ,
  61. move_screentags
  62. },
  63. { "Toggle on tag",
  64. toggle_screentags
  65. },
  66. { "Stop task",
  67. function()
  68. awful.spawn("kill "..tostring(client.focus.pid))
  69. end
  70. },
  71. { "Kill task",
  72. function()
  73. awful.spawn("kill -s KILL "..tostring(client.focus.pid))
  74. end
  75. },
  76. { "Debug info",
  77. {
  78. before = {
  79. require("widgets.window-debug")()
  80. }
  81. }
  82. }
  83. },
  84. vertical = true
  85. })
  86. return function(c)
  87. local buttons = gears.table.join(
  88. awful.button({ }, 1, function()
  89. c:emit_signal("request::activate", "titlebar", {raise = true})
  90. awful.mouse.client.move(c)
  91. end),
  92. awful.button({ }, 3, function()
  93. c:emit_signal("request::activate", "titlebar", {raise = true})
  94. awful.mouse.client.resize(c)
  95. end)
  96. )
  97. c.menu_button = awful.titlebar.widget.iconwidget(c)
  98. -- A little trick we do to conserve memory and cpu usage on regenerating
  99. -- buttons is we pop up a menu in the location of the icon
  100. -- and insert buttons into the controls widget layout.
  101. c.hidden_floatingbutton = awful.titlebar.widget.floatingbutton(c)
  102. c.hidden_stickybutton = awful.titlebar.widget.stickybutton(c)
  103. c.hidden_ontopbutton = awful.titlebar.widget.ontopbutton(c)
  104. c.menu_button:connect_signal("button::press", function()
  105. menu_widget.toggle()
  106. if controls_widget then
  107. controls_widget:reset()
  108. controls_widget:add(c.hidden_floatingbutton)
  109. controls_widget:add(c.hidden_stickybutton)
  110. controls_widget:add(c.hidden_ontopbutton)
  111. end
  112. c:emit_signal("request::activate", "titlebar", {raise = true})
  113. end)
  114. c:connect_signal("unfocus",function()
  115. if menu_widget.visible then
  116. menu_widget.toggle(0,0)
  117. end
  118. end)
  119. return awful.titlebar(c) : setup {
  120. { -- Left
  121. c.menu_button,
  122. layout = wibox.layout.fixed.horizontal
  123. },
  124. { -- Middle
  125. awful.titlebar.widget.titlewidget(c),
  126. buttons = buttons,
  127. layout = wibox.layout.flex.horizontal
  128. },
  129. { -- Right
  130. {
  131. {
  132. awful.titlebar.widget.maximizedbutton(c),
  133. awful.titlebar.widget.minimizebutton (c),
  134. awful.titlebar.widget.closebutton (c),
  135. layout = wibox.layout.fixed.horizontal(),
  136. widget = wibox.container.margin,
  137. margins = 3
  138. },
  139. widget = wibox.container.background,
  140. shape = gears.shape.rounded_bar,
  141. bg = {
  142. type = "linear",
  143. from = { 0, 15 },
  144. to = { 0, 0},
  145. stops = { { 0, "#5d5d5955"} , {1, "39383555"} }
  146. },
  147. },
  148. widget = wibox.container.margin,
  149. margins = 2
  150. },
  151. spacing = 10,
  152. layout = wibox.layout.align.horizontal,
  153. }
  154. end