2024-02-19 19:41:33 -08:00
|
|
|
local awful = require("awful")
|
|
|
|
local gears = require("gears")
|
|
|
|
local wibox = require("wibox")
|
2024-02-24 14:01:36 -08:00
|
|
|
local beautiful = require("beautiful")
|
|
|
|
local helpers = require("helpers")
|
|
|
|
|
|
|
|
local dpi = beautiful.xresources.apply_dpi
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
-- Make Widgets
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
-- Song's Title
|
|
|
|
local title = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
title.font = helpers.ui.set_font("Medium 16")
|
2024-02-18 20:26:15 -08:00
|
|
|
title.align = "left"
|
|
|
|
title.valign = "bottom"
|
|
|
|
|
|
|
|
-- Song's Artist
|
|
|
|
local artist = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
artist.font = helpers.ui.set_font("Regular 16")
|
2024-02-18 20:26:15 -08:00
|
|
|
artist.align = "left"
|
|
|
|
artist.valign = "bottom"
|
|
|
|
|
|
|
|
-- Song's Length
|
|
|
|
local length = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
length.font = helpers.ui.set_font("Regular 14")
|
2024-02-18 20:26:15 -08:00
|
|
|
length.align = "center"
|
|
|
|
length.valign = "center"
|
|
|
|
|
|
|
|
-- Player's Button
|
|
|
|
local toggle = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
toggle.font = helpers.ui.set_font("26")
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
toggle:buttons(gears.table.join(awful.button({}, 1, function()
|
|
|
|
awful.spawn("mpc toggle", false)
|
2024-02-24 14:01:36 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
if toggle.markup:match("") then
|
|
|
|
toggle.markup = ""
|
|
|
|
else
|
|
|
|
toggle.markup = ""
|
|
|
|
end
|
|
|
|
end)))
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
local next = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
next.font = helpers.ui.set_font("26")
|
2024-02-19 19:41:33 -08:00
|
|
|
next.markup = ""
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
next:buttons(gears.table.join(awful.button({}, 1, function()
|
|
|
|
awful.spawn("mpc next", false)
|
|
|
|
end)))
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
local back = wibox.widget.textbox()
|
2024-02-24 14:01:36 -08:00
|
|
|
back.font = helpers.ui.set_font("26")
|
2024-02-19 19:41:33 -08:00
|
|
|
back.markup = ""
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
back:buttons(gears.table.join(awful.button({}, 1, function()
|
|
|
|
awful.spawn("mpc prev", false)
|
|
|
|
end)))
|
2024-02-18 20:26:15 -08:00
|
|
|
|
|
|
|
-- Get data
|
|
|
|
awesome.connect_signal("signal::player", function(t, a, l, s)
|
|
|
|
if not s:match("playing") then
|
2024-02-19 19:41:33 -08:00
|
|
|
toggle.markup = ""
|
2024-02-18 20:26:15 -08:00
|
|
|
else
|
2024-02-19 19:41:33 -08:00
|
|
|
toggle.markup = ""
|
2024-02-18 20:26:15 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
title.markup = t
|
|
|
|
artist.markup = a
|
|
|
|
length.markup = l
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Grouping Widgets
|
|
|
|
---------------------
|
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
local buttons = wibox.widget({
|
2024-02-18 20:26:15 -08:00
|
|
|
back,
|
|
|
|
toggle,
|
|
|
|
next,
|
|
|
|
spacing = dpi(11),
|
|
|
|
layout = wibox.layout.fixed.horizontal,
|
2024-02-19 19:41:33 -08:00
|
|
|
})
|
2024-02-18 20:26:15 -08:00
|
|
|
|
2024-02-19 19:41:33 -08:00
|
|
|
return wibox.widget({
|
2024-02-18 20:26:15 -08:00
|
|
|
{
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
title,
|
|
|
|
artist,
|
|
|
|
spacing = dpi(12),
|
|
|
|
layout = wibox.layout.fixed.vertical,
|
|
|
|
},
|
2024-02-19 19:41:33 -08:00
|
|
|
expand = "none",
|
2024-02-18 20:26:15 -08:00
|
|
|
layout = wibox.layout.align.vertical,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
{
|
|
|
|
length,
|
|
|
|
{
|
|
|
|
nil,
|
|
|
|
buttons,
|
2024-02-19 19:41:33 -08:00
|
|
|
expand = "none",
|
2024-02-18 20:26:15 -08:00
|
|
|
layout = wibox.layout.align.horizontal,
|
|
|
|
},
|
|
|
|
spacing = dpi(6),
|
|
|
|
layout = wibox.layout.fixed.vertical,
|
|
|
|
},
|
2024-02-24 14:01:36 -08:00
|
|
|
top = dpi(30),
|
2024-02-18 20:26:15 -08:00
|
|
|
bottom = 0,
|
|
|
|
layout = wibox.container.margin,
|
|
|
|
},
|
|
|
|
layout = wibox.layout.flex.horizontal,
|
2024-02-19 19:41:33 -08:00
|
|
|
})
|