aWM: Make playing widget work with mpd-mpris

This commit is contained in:
tarneo 2024-01-09 14:56:33 +01:00
parent 63b1c30f61
commit 7f9d68740b
Signed by: tarneo
GPG Key ID: BA924E53D0EB3FCC
3 changed files with 8 additions and 2 deletions

View File

@ -6,9 +6,10 @@ local widget = wibox.widget.textbox()
local function daemon ()
awful.spawn.easy_async_with_shell(
'playerctl metadata --format "{{ artist }} - {{ title}}"',
'playerctl -p $(playerctl -l | grep mpd) metadata --format "{{ artist }} - {{ title }}"',
function(stdout)
if stdout ~= "" then
stdout = stdout:gsub('%\n$', '')
if stdout ~= "" and stdout ~= " - " then
widget:set_markup("󰝚 " .. stdout)
else
widget:set_markup("󰝚 Not playing")

View File

@ -40,6 +40,10 @@ dofile(awesome_conf_dir .. "signals.lua")
awful.spawn.with_shell("pgrep mpd || mpd")
-- Mpris: allows controlling mpd with playerctl (media keys, playing widget).
-- We sleep before starting to allow mpd to start first.
awful.spawn.with_shell("pgrep mpd-mpris || {sleep 1; mpd-mpris -host localhost}")
awful.spawn.with_shell("pgrep signal-desktop || signal-desktop --start-in-tray")
-- Keyboard manager: automatically set layouts for the different keyboards I use

View File

@ -42,6 +42,7 @@ brightnessctl
xss-lock
i3lock
imagemagick
mpd-mpris # for playerctl to work with mpd
###############################