dotfiles/.config/awesome/ui/info-panel/player.lua

113 lines
2.2 KiB
Lua
Raw Normal View History

2024-02-19 19:41:33 -08:00
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
2024-02-20 19:13:52 -08:00
local beautiful = require("beautiful").get()
local dpi = require("beautiful.xresources").apply_dpi
-- Make Widgets
-----------------
-- Song's Title
local title = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
title.font = beautiful.font_name .. "Medium 16"
title.align = "left"
title.valign = "bottom"
-- Song's Artist
local artist = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
artist.font = beautiful.font_name .. "Regular 16"
artist.align = "left"
artist.valign = "bottom"
-- Song's Length
local length = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
length.font = beautiful.font_name .. "Regular 14"
length.align = "center"
length.valign = "center"
-- Player's Button
local toggle = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
toggle.font = beautiful.font_name .. "26"
2024-02-19 19:41:33 -08:00
toggle:buttons(gears.table.join(awful.button({}, 1, function()
awful.spawn("mpc toggle", false)
if toggle.markup:match("󰏤") then
toggle.markup = "󰐊"
else
toggle.markup = "󰏤"
end
end)))
local next = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
next.font = beautiful.font_name .. "26"
next.markup = "󰒭"
2024-02-19 19:41:33 -08:00
next:buttons(gears.table.join(awful.button({}, 1, function()
awful.spawn("mpc next", false)
end)))
local back = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
back.font = beautiful.font_name .. "26"
back.markup = "󰒮"
2024-02-19 19:41:33 -08:00
back:buttons(gears.table.join(awful.button({}, 1, function()
awful.spawn("mpc prev", false)
end)))
-- 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 = "󰐊"
else
2024-02-19 19:41:33 -08:00
toggle.markup = "󰏤"
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({
back,
toggle,
next,
spacing = dpi(11),
layout = wibox.layout.fixed.horizontal,
2024-02-19 19:41:33 -08:00
})
2024-02-19 19:41:33 -08:00
return wibox.widget({
{
nil,
{
title,
artist,
spacing = dpi(12),
layout = wibox.layout.fixed.vertical,
},
2024-02-19 19:41:33 -08:00
expand = "none",
layout = wibox.layout.align.vertical,
},
{
nil,
nil,
{
length,
{
nil,
buttons,
2024-02-19 19:41:33 -08:00
expand = "none",
layout = wibox.layout.align.horizontal,
},
spacing = dpi(6),
layout = wibox.layout.fixed.vertical,
},
top = 30,
bottom = 0,
layout = wibox.container.margin,
},
layout = wibox.layout.flex.horizontal,
2024-02-19 19:41:33 -08:00
})