1
0
Fork 0

add mpd2nheko

This commit is contained in:
tastytea 2022-12-07 17:17:17 +01:00
parent 63c41b480b
commit 2cdbc7dbed
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 27 additions and 0 deletions

27
.local/bin/mpd2nheko Executable file
View File

@ -0,0 +1,27 @@
#!/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