sep-widget.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. local awful = require("awful")
  2. local wibox = require("wibox")
  3. local beautiful = require("beautiful")
  4. local HOME = os.getenv("HOME")
  5. local TERMINAL = os.getenv("TERMINAL") or "xterm"
  6. local SHELL = os.getenv("SHELL") or "/usr/bin/sh"
  7. local sep_widget = {}
  8. local function worker(user_args)
  9. local args = user_args or {}
  10. local fg_color = args.fg_color or beautiful.fg_normal
  11. local bg_color = args.bg_color or beautiful.bg_color or "#00000000"
  12. local font_name = args.font_name or beautiful.font
  13. local icon = args.icon or "|"
  14. local icon_size = args.icon_size or 11
  15. local font_name_no_size = font_name:gsub("%s%d+$", " ")
  16. local font_size_icon = font_name_no_size .. icon_size or font_name_no_size .. icon_size
  17. local sep_widget = wibox.widget {
  18. {
  19. id = "txt_icon",
  20. text = icon,
  21. font = font_size_icon,
  22. widget = wibox.widget.textbox,
  23. },
  24. valign = "center",
  25. layout = wibox.layout.align.horizontal,
  26. }
  27. -- Set fg and bg colors for sep_widget
  28. local sep_widget_clr = wibox.widget.background()
  29. sep_widget_clr:set_widget(sep_widget)
  30. sep_widget_clr:set_fg(fg_color)
  31. return sep_widget_clr
  32. end
  33. return setmetatable(sep_widget, { __call = function(_, ...) return worker(...) end })