1
0
Fork 0
dotfiles/.local/bin/mpd2nheko

31 lines
859 B
Bash
Executable File

#!/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
local title=$(mpc current --format '%title%')
if [[ -z ${title} ]]; then
dbus-send --print-reply \
--dest=im.nheko.Nheko / im.nheko.Nheko.setStatusMessage \
"string:"
sleep 10s
continue
fi
local artist=$(mpc current --format '%albumartist%')
local album=$(mpc current --format '%album%')
local mpdstatus="np: ${title} by ${artist} [from ${album}]"
if [[ ${mpdstatus} != ${oldstatus} ]]; then
dbus-send --print-reply \
--dest=im.nheko.Nheko / im.nheko.Nheko.setStatusMessage \
"string:${mpdstatus}"
oldstatus=${mpdstatus}
fi
sleep 1
done