28 lines
733 B
Plaintext
28 lines
733 B
Plaintext
|
#!/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
|
||
|
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
|