dotfiles/.local/bin/mpd2nheko

26 lines
630 B
Plaintext
Raw Normal View History

2022-12-07 17:17:17 +01:00
#!/usr/bin/env zsh
# Get current song info from MPD and send it via DBUS to nheko to display as
# status message.
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
local oldstatus
while :; do
2022-12-07 18:15:08 +01:00
local mpdstatus=$(mpc current --format \
'[np: %title%[ by [%albumartist%|%artist%][ \[from %album%\]]]]')
2022-12-07 17:17:17 +01:00
if [[ ${mpdstatus} != ${oldstatus} ]]; then
dbus-send --print-reply \
--dest=im.nheko.Nheko / im.nheko.Nheko.setStatusMessage \
"string:${mpdstatus}"
oldstatus=${mpdstatus}
fi
2022-12-07 18:15:08 +01:00
if [[ -z ${mpdstatus} ]]; then
sleep 10
else
sleep 1
fi
2022-12-07 17:17:17 +01:00
done