Facebook
From yz, 1 Year ago, written in Lua.
Embed
Download Paste or View Raw
Hits: 127
  1. local _M = {}
  2.  
  3. local awful = require'awful'
  4. local gears = require'gears'
  5. local hotkeys_popup = require'awful.hotkeys_popup'
  6. local beautiful = require'beautiful'
  7. local wibox = require'wibox'
  8. local lain  = require'lain'
  9. local dpi   = require("beautiful.xresources").apply_dpi
  10.  
  11. local apps = require'config.apps'
  12. local mod = require'bindings.mod'
  13.  
  14. local markup = lain.util.markup
  15. local gray   = "#928374"
  16.  
  17. local first = wibox.widget.textbox(markup.font("Symbols Nerd Font 10", "                "))
  18. local spr   = wibox.widget.textbox('  ')
  19.  
  20. local shape1 = function(cr, width, height)
  21.    gears.shape.rounded_rect(cr, width, height, 2)
  22. end
  23.  
  24. _M.textclock      = wibox.widget.textclock( " %H:%M " )
  25. _M.textclock.font = "JetBrainsMono Nerd Font 10"
  26. _M.vol = lain.widget.pulse {
  27.     settings = function()
  28.         header = " Vol "
  29.         vlevel = volume_now.left .. "% "
  30.         if volume_now.muted == "yes" then
  31.             vlevel = vlevel .. " M"
  32.         end
  33.         widget:set_markup(markup.font("JetBrainsMono Nerd Font 10", markup(gray, header) .. vlevel))
  34.     end
  35. }
  36. -- MPD
  37. _M.mpd = lain.widget.mpd({
  38.     settings = function()
  39.         album  = mpd_now.album .. " "
  40.         title  = mpd_now.title  .. " "
  41.  
  42.         if mpd_now.state == "pause" then
  43.             artist = "mpd "
  44.             title  = "paused "
  45.         elseif mpd_now.state == "stop" then
  46.             artist = ""
  47.             title  = ""
  48.         end
  49.  
  50.         widget:set_markup(markup.font("JetBrainsMono Nerd Font 10", markup(gray, artist) .. title))
  51.     end
  52. })
  53.  
  54. function _M.create_taglist(s)
  55.    return awful.widget.taglist{
  56.       screen = s,
  57.       filter = awful.widget.taglist.filter.all,
  58.       forced_height = 10,
  59.       buttons = {
  60.          awful.button{
  61.             modifiers = {},
  62.             button    = 1,
  63.             on_press  = function(t) t:view_only() end,
  64.          },
  65.          awful.button{
  66.             modifiers = {mod.super},
  67.             button    = 1,
  68.             on_press  = function(t)
  69.                if client.focus then
  70.                   client.focus:move_to_tag(t)
  71.                end
  72.             end,
  73.          },
  74.          awful.button{
  75.             modifiers = {},
  76.             button    = 3,
  77.             on_press  = awful.tag.viewtoggle,
  78.          },
  79.          awful.button{
  80.             modifiers = {mod.super},
  81.             button    = 3,
  82.             on_press  = function(t)
  83.                if client.focus then
  84.                   client.focus:toggle_tag(t)
  85.                end
  86.             end
  87.          },
  88.          awful.button{
  89.             modifiers = {},
  90.             button    = 4,
  91.             on_press  = function(t) awful.tag.viewprev(t.screen) end,
  92.          },
  93.          awful.button{
  94.             modifiers = {},
  95.             button    = 5,
  96.             on_press  = function(t) awful.tag.viewnext(t.screen) end,
  97.          },
  98.       }
  99.    }
  100. end
  101.  
  102. function _M.create_wibox(s)
  103.    return awful.wibar{
  104.       screen = s,
  105.       position = 'top',
  106.       height = dpi(35),
  107.       widget = {
  108.            layout = wibox.layout.stack,
  109.            {
  110.              layout = wibox.layout.align.horizontal,
  111.              { -- left widgets
  112.                 layout = wibox.layout.fixed.horizontal,
  113.                 first,
  114.                 {
  115.                    {
  116.                       {s.taglist,
  117.                        left = 5,
  118.                        right = 5,
  119.                        top = 4,
  120.                        bottom = 4,
  121.                        widget = wibox.container.margin
  122.                       },
  123.                       bg = "#282828",
  124.                       shape = shape1,
  125.                       widget = wibox.container.background
  126.                    },
  127.                    layout = wibox.container.place
  128.                 },
  129.                 s.promptbox,
  130.                 spr,
  131.             },
  132.             nil,
  133.             { -- right widgets
  134.               layout = wibox.layout.fixed.horizontal,
  135.               {
  136.                  {
  137.                     {_M.textclock,
  138.                      left = 5,
  139.                      right = 5,
  140.                      top = 3,
  141.                      bottom = 3,
  142.                      widget = wibox.container.margin
  143.                     },
  144.                     valign = "center",
  145.                     halign = "center",
  146.                     bg = "#282828",
  147.                     shape = shape1,
  148.                     widget = wibox.container.background
  149.                  },
  150.                  layout = wibox.container.place
  151.               },
  152.               spr,
  153.               wibox.widget.systray(),
  154.             },
  155.            },
  156.            {
  157.               {
  158.                  {_M.vol,
  159.                   left = 5,
  160.                   right = 5,
  161.                   top = 3,
  162.                   bottom = 3,
  163.                   widget = wibox.container.margin
  164.                  },
  165.                 valign = "center",
  166.                 halign = "center",
  167.                 bg = "#282828",
  168.                 shape = shape1,
  169.                 widget = wibox.container.background
  170.               },
  171.               layout = wibox.container.place
  172.            },
  173.            {
  174.               {
  175.                  {_M.mpd,
  176.                   left = 5,
  177.                   right = 5,
  178.                   top = 3,
  179.                   bottom = 3,
  180.                   widget = wibox.container.margin
  181.                  },
  182.                 valign = "center",
  183.                 halign = "center",
  184.                         bg = "#282828",
  185.                         shape = shape1,
  186.                         widget = wibox.container.background
  187.              },
  188.              layout = wibox.container.place
  189.            }
  190.       }
  191.    }
  192. end
  193.  
  194. return _M
  195.