Update mpris plugin with cover art
This commit is contained in:
parent
8d5ee408cf
commit
0ff84042ab
5 changed files with 145 additions and 27 deletions
22
bin/get_mpris_art.sh
Executable file
22
bin/get_mpris_art.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
read -d'\n' -ra PLAYERS <<<"$(playerctl -l 2>/dev/null)"
|
||||||
|
declare -a PAUSED
|
||||||
|
for player in "${PLAYERS[@]}"; do
|
||||||
|
[ "$player" = "playerctld" ] && continue;
|
||||||
|
|
||||||
|
p_status=$(playerctl -p "$player" status 2>/dev/null)
|
||||||
|
|
||||||
|
# if we have one playing, we'll use it and EXIT
|
||||||
|
if [ "$p_status" = "Playing" ]; then
|
||||||
|
echo $(playerctl -p $player metadata | grep artUrl | awk '{$1=$2=""; print $0}')
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$p_status" = "Paused" ] && PAUSED+=("$player")
|
||||||
|
done
|
||||||
|
|
||||||
|
# if we have a paused, show it otherwise assume there are no players or have all stopped
|
||||||
|
if [ -n "${PAUSED[0]}" ]; then
|
||||||
|
echo $(playerctl -p ${PAUSED[0]} metadata | grep artUrl | awk '{$1=$2=""; print $0}')
|
||||||
|
fi
|
||||||
|
|
|
@ -35,17 +35,17 @@ get_info() {
|
||||||
|
|
||||||
# if not "icon", display information and return
|
# if not "icon", display information and return
|
||||||
if [ "$2" != "icon" ]; then
|
if [ "$2" != "icon" ]; then
|
||||||
|
printf "$title"
|
||||||
artist=$(extract_meta artist)
|
artist=$(extract_meta artist)
|
||||||
[ -z "$artist" ] && artist=$(extract_meta albumArtist)
|
[ -z "$artist" ] && artist=$(extract_meta albumArtist)
|
||||||
|
|
||||||
if [ -n "$artist" ]; then
|
if [ -n "$artist" ]; then
|
||||||
album=$(extract_meta album)
|
album=$(extract_meta album)
|
||||||
[ -n "$album" ] && echo -n " $album "
|
[ -n "$album" ] && printf "\nfrom $album"
|
||||||
|
|
||||||
echo -n " ﴁ $artist "
|
printf "\nby $artist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$title"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
85
crylia_bar/bottom_right_bar.lua
Normal file
85
crylia_bar/bottom_right_bar.lua
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
--------------------------------------------------------------------------------------------------------------
|
||||||
|
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||||
|
--------------------------------------------------------------------------------------------------------------
|
||||||
|
-- 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 wibox = require("wibox")
|
||||||
|
|
||||||
|
return function(s, widgets)
|
||||||
|
|
||||||
|
local bottom_right = awful.popup {
|
||||||
|
widget = wibox.container.background,
|
||||||
|
ontop = false,
|
||||||
|
bg = color["Grey900"],
|
||||||
|
visible = true,
|
||||||
|
screen = s,
|
||||||
|
maximum_height = dpi(80),
|
||||||
|
placement = function(c) awful.placement.bottom_left(c, { margins = dpi(5) }) end,
|
||||||
|
shape = function(cr, width, height)
|
||||||
|
gears.shape.rounded_rect(cr, width, height, 5)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
bottom_right:struts {
|
||||||
|
bottom = 85
|
||||||
|
}
|
||||||
|
|
||||||
|
local function prepare_widgets(widgets)
|
||||||
|
local layout = {
|
||||||
|
layout = wibox.layout.fixed.horizontal
|
||||||
|
}
|
||||||
|
if #widgets == 1 then
|
||||||
|
table.insert(layout,
|
||||||
|
{
|
||||||
|
widgets[1],
|
||||||
|
widget = wibox.container.margin
|
||||||
|
})
|
||||||
|
return layout;
|
||||||
|
end
|
||||||
|
for i, widget in pairs(widgets) do
|
||||||
|
if i == 1 then
|
||||||
|
table.insert(layout,
|
||||||
|
{
|
||||||
|
widget,
|
||||||
|
left = dpi(6),
|
||||||
|
right = dpi(3),
|
||||||
|
top = dpi(6),
|
||||||
|
bottom = dpi(6),
|
||||||
|
widget = wibox.container.margin
|
||||||
|
})
|
||||||
|
elseif i == #widgets then
|
||||||
|
table.insert(layout,
|
||||||
|
{
|
||||||
|
widget,
|
||||||
|
left = dpi(3),
|
||||||
|
right = dpi(6),
|
||||||
|
top = dpi(6),
|
||||||
|
bottom = dpi(6),
|
||||||
|
widget = wibox.container.margin
|
||||||
|
})
|
||||||
|
else
|
||||||
|
table.insert(layout,
|
||||||
|
{
|
||||||
|
widget,
|
||||||
|
left = dpi(3),
|
||||||
|
right = dpi(3),
|
||||||
|
top = dpi(6),
|
||||||
|
bottom = dpi(6),
|
||||||
|
widget = wibox.container.margin
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return layout
|
||||||
|
end
|
||||||
|
|
||||||
|
bottom_right:setup {
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
prepare_widgets(widgets),
|
||||||
|
layout = wibox.layout.align.horizontal
|
||||||
|
}
|
||||||
|
end
|
|
@ -46,7 +46,7 @@ awful.screen.connect_for_each_screen(
|
||||||
|
|
||||||
require("crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist })
|
require("crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist })
|
||||||
require("crylia_bar.center_bar")(s, { s.tasklist })
|
require("crylia_bar.center_bar")(s, { s.tasklist })
|
||||||
require("crylia_bar.right_bar")(s, { s.mpris, s.audio, s.date, s.clock, s.powerbutton })
|
require("crylia_bar.right_bar")(s, { s.audio, s.date, s.clock, s.powerbutton })
|
||||||
--require("crylia_bar.dock")(s, user_vars.dock_programs)
|
--require("crylia_bar.dock")(s, user_vars.dock_programs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ awful.screen.connect_for_each_screen(
|
||||||
require("crylia_bar.left_bar")(s, { s.layoutlist, s.taglist })
|
require("crylia_bar.left_bar")(s, { s.layoutlist, s.taglist })
|
||||||
require("crylia_bar.center_bar")(s, { s.tasklist })
|
require("crylia_bar.center_bar")(s, { s.tasklist })
|
||||||
require("crylia_bar.right_bar")(s, { s.gpu_temp, s.cpu_temp, s.ram_info, s.kblayout, s.bluetooth, s.network, s.clock, s.powerbutton })
|
require("crylia_bar.right_bar")(s, { s.gpu_temp, s.cpu_temp, s.ram_info, s.kblayout, s.bluetooth, s.network, s.clock, s.powerbutton })
|
||||||
|
require("crylia_bar.bottom_right_bar")(s, { s.mpris })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
-- Awesome Libs
|
-- Awesome Libs
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local color = require("src.theme.colors")
|
local color = require("src.theme.colors")
|
||||||
|
local cat = require("src.theme.catppuccin")
|
||||||
local dpi = require("beautiful").xresources.apply_dpi
|
local dpi = require("beautiful").xresources.apply_dpi
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
local watch = awful.widget.watch
|
local watch = awful.widget.watch
|
||||||
|
@ -20,38 +21,38 @@ return function()
|
||||||
local mpris_widget = wibox.widget {
|
local mpris_widget = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
-- {
|
{
|
||||||
-- {
|
{
|
||||||
-- {
|
{
|
||||||
-- id = "icon",
|
id = "icon",
|
||||||
-- widget = wibox.widget.imagebox,
|
widget = wibox.widget.imagebox,
|
||||||
-- image = gears.color.recolor_image(icon_dir .. "cd.svg", color["Grey900"]),
|
resize = true
|
||||||
-- resize = false
|
},
|
||||||
-- },
|
id = "icon_layout",
|
||||||
-- id = "icon_layout",
|
clip_shape = function(cr, width, height)
|
||||||
-- widget = wibox.container.place
|
gears.shape.rounded_rect(cr, width, height, 2)
|
||||||
-- },
|
end,
|
||||||
-- top = dpi(2),
|
widget = wibox.container.place
|
||||||
-- widget = wibox.container.margin,
|
},
|
||||||
-- id = "icon_margin"
|
widget = wibox.container.margin,
|
||||||
-- },
|
id = "icon_margin"
|
||||||
-- spacing = dpi(10),
|
},
|
||||||
|
spacing = dpi(10),
|
||||||
{
|
{
|
||||||
id = "label",
|
id = "label",
|
||||||
align = "center",
|
font = "UbuntuMono Nerd Font, Bold 8",
|
||||||
|
align = "left",
|
||||||
valign = "center",
|
valign = "center",
|
||||||
font = "UbuntuMono Nerd Font, Bold",
|
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
},
|
},
|
||||||
id = "mpris_layout",
|
id = "mpris_layout",
|
||||||
layout = wibox.layout.fixed.horizontal
|
layout = wibox.layout.fixed.horizontal
|
||||||
},
|
},
|
||||||
id = "container",
|
id = "container",
|
||||||
left = dpi(8),
|
|
||||||
right = dpi(8),
|
right = dpi(8),
|
||||||
widget = wibox.container.margin
|
widget = wibox.container.margin
|
||||||
},
|
},
|
||||||
bg = color["Orange200"],
|
bg = cat["Lavender"],
|
||||||
fg = color["Grey900"],
|
fg = color["Grey900"],
|
||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_rect(cr, width, height, 5)
|
gears.shape.rounded_rect(cr, width, height, 5)
|
||||||
|
@ -59,13 +60,22 @@ return function()
|
||||||
widget = wibox.container.background
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
|
|
||||||
Hover_signal(mpris_widget, color["Orange200"], color["Grey900"])
|
Hover_signal(mpris_widget, cat["Lavender"], color["Grey900"])
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[[ bash -c "$HOME/.config/awesome/bin/get_mpris_status_hide_album.sh" ]],
|
[[ bash -c "$HOME/.config/awesome/bin/get_mpris_status.sh" ]],
|
||||||
5,
|
5,
|
||||||
function(_, stdout)
|
function(_, stdout)
|
||||||
mpris_widget.container.mpris_layout.label.text = stdout:gsub("\n", "")
|
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))
|
awesome.emit_signal("update::mpris_widget", tostring(stdout))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue