Advertisement
Guest User

Untitled

a guest
Oct 5th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. local awful = require("awful")
  2. local gears = require("gears")
  3. local beautiful = require("beautiful")
  4. local wibox = require("wibox")
  5.  
  6. local helpers = {}
  7.  
  8. -- Create rounded rectangle shape
  9. helpers.rrect = function(radius)
  10. return function(cr, width, height)
  11. --gears.shape.partially_rounded_rect(cr, width, height, true, true, false, false, 12)
  12. gears.shape.rounded_rect(cr, width, height, radius)
  13. --gears.shape.octogon(cr, width, height, radius)
  14. --gears.shape.rounded_bar(cr, width, height)
  15. end
  16. end
  17.  
  18. -- Create info bubble shape
  19. -- TODO
  20. helpers.infobubble = function(radius)
  21. return function(cr, width, height)
  22. gears.shape.infobubble(cr, width, height, radius)
  23. end
  24. end
  25.  
  26. -- Create rectangle shape
  27. helpers.rect = function()
  28. return function(cr, width, height)
  29. gears.shape.rectangle(cr, width, height)
  30. end
  31. end
  32.  
  33. function helpers.colorize_text(txt, fg)
  34. return "<span foreground='" .. fg .."'>" .. txt .. "</span>"
  35. end
  36.  
  37. function helpers.client_menu_toggle()
  38. local instance = nil
  39.  
  40. return function ()
  41. if instance and instance.wibox.visible then
  42. instance:hide()
  43. instance = nil
  44. else
  45. instance = awful.menu.clients({ theme = { width = 250 } })
  46. end
  47. end
  48. end
  49.  
  50. function helpers.pad(size)
  51. local str = ""
  52. for i = 1, size do
  53. str = str .. " "
  54. end
  55. local pad = wibox.widget.textbox(str)
  56. return pad
  57. end
  58.  
  59. function helpers.move_to_edge(c, direction)
  60. local workarea = awful.screen.focused().workarea
  61. local client_geometry = c:geometry()
  62. if direction == "up" then
  63. c:geometry({ nil, y = workarea.y + beautiful.screen_margin * 2, nil, nil })
  64. elseif direction == "down" then
  65. c:geometry({ nil, y = workarea.height + workarea.y - client_geometry.height - beautiful.screen_margin * 2 - beautiful.border_width * 2, nil, nil })
  66. elseif direction == "left" then
  67. c:geometry({ x = workarea.x + beautiful.screen_margin * 2, nil, nil, nil })
  68. elseif direction == "right" then
  69. c:geometry({ x = workarea.width + workarea.x - client_geometry.width - beautiful.screen_margin * 2 - beautiful.border_width * 2, nil, nil, nil })
  70. end
  71. end
  72.  
  73. function helpers.create_titlebar(c, titlebar_buttons, titlebar_position, titlebar_size)
  74. awful.titlebar(c, {font = beautiful.titlebar_font, position = titlebar_position, size = titlebar_size}) : setup {
  75. {
  76. buttons = titlebar_buttons,
  77. layout = wibox.layout.fixed.horizontal
  78. },
  79. {
  80. buttons = titlebar_buttons,
  81. layout = wibox.layout.fixed.horizontal
  82. },
  83. {
  84. buttons = titlebar_buttons,
  85. layout = wibox.layout.fixed.horizontal
  86. },
  87. layout = wibox.layout.align.horizontal
  88. }
  89. end
  90.  
  91. return helpers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement