MPD:使用Linux bash脚本接收实际的mpd-status

时间:2015-05-19 10:58:50

标签: linux bash raspberry-pi mpd

我想知道如何使用linux bash脚本接收mpd播放器的实际状态。我知道如何开始和停止播放器...

#!/bin/bash
mpc play
mpc volume +1
mpc stop

...但我需要知道mpd是否正在播放一首歌。此外,当前的音量设置也很有趣。

我尝试使用mpcstatus=cat /var/tmp/mpd_statusactvol=cat /var/tmp/mpd_volume接收它,但文件不存在。我在RaspberryPi上与Volumio / Debian合作。

1 个答案:

答案 0 :(得分:3)

我知道了!

玩:

if mpc status | grep playing >/dev/nul      # If mpd is playing
then
 command... 
fi

体积:

ACTVOL=`mpc status | sed -n '/volume/p' | cut -c8-10 | sed 's/^[ \t]*//'`
相关问题