85 lines
2.3 KiB
Lua
85 lines
2.3 KiB
Lua
---------------------------------
|
|
-- This is the mPris2 widget --
|
|
---------------------------------
|
|
|
|
-- Awesome Libs
|
|
local awful = require("awful")
|
|
local color = require("src.theme.colors")
|
|
local cat = require("src.theme.catppuccin")
|
|
local dpi = require("beautiful").xresources.apply_dpi
|
|
local gears = require("gears")
|
|
local watch = awful.widget.watch
|
|
local wibox = require("wibox")
|
|
require("src.core.signals")
|
|
|
|
-- Icon directory path
|
|
local icon_dir = awful.util.getdir("config") .. "src/assets/icons/mpris/"
|
|
|
|
-- Returns the mPris widget
|
|
return function()
|
|
|
|
local mpris_widget = wibox.widget {
|
|
{
|
|
{
|
|
{
|
|
{
|
|
{
|
|
id = "icon",
|
|
widget = wibox.widget.imagebox,
|
|
resize = true
|
|
},
|
|
id = "icon_layout",
|
|
clip_shape = function(cr, width, height)
|
|
gears.shape.rounded_rect(cr, width, height, 2)
|
|
end,
|
|
widget = wibox.container.place
|
|
},
|
|
widget = wibox.container.margin,
|
|
id = "icon_margin"
|
|
},
|
|
spacing = dpi(10),
|
|
{
|
|
id = "label",
|
|
font = "UbuntuMono Nerd Font, Bold 8",
|
|
align = "left",
|
|
valign = "center",
|
|
widget = wibox.widget.textbox
|
|
},
|
|
id = "mpris_layout",
|
|
layout = wibox.layout.fixed.horizontal
|
|
},
|
|
id = "container",
|
|
right = dpi(8),
|
|
widget = wibox.container.margin
|
|
},
|
|
bg = cat["Lavender"],
|
|
fg = cat["Crust"],
|
|
shape = function(cr, width, height)
|
|
gears.shape.rounded_rect(cr, width, height, 5)
|
|
end,
|
|
widget = wibox.container.background
|
|
}
|
|
|
|
Hover_signal(mpris_widget, cat["Lavender"], cat["Crust"])
|
|
|
|
watch(
|
|
[[ bash -c "$HOME/.config/awesome/bin/get_mpris_status.sh" ]],
|
|
5,
|
|
function(_, stdout)
|
|
mpris_widget.container.mpris_layout.label.text = stdout
|
|
awesome.emit_signal("update::mpris_widget", tostring(stdout))
|
|
end
|
|
)
|
|
|
|
watch(
|
|
[[ bash -c "$HOME/.config/awesome/bin/get_mpris_art.sh" ]],
|
|
5,
|
|
function(_, stdout)
|
|
mpris_widget.container.mpris_layout.icon_margin.icon_layout.icon:set_image(gears.surface.load_uncached(stdout:gsub("\n", ""):gsub("file://", "")))
|
|
awesome.emit_signal("update::mpris_widget", tostring(stdout))
|
|
end
|
|
)
|
|
|
|
return mpris_widget
|
|
end
|
|
|