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

标签 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 接收它,但文件不存在。我正在使用 Volumio/RaspberryPi 上的 Debian。

最佳答案

我知道了!

播放:

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]*//'`

关于linux - MPD:使用 Linux bash 脚本接收实际的 mpd-status,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30323721/

相关文章:

raspberry-pi - kworker 在空闲系统上的 CPU 使用率很高

linux - bc 忽略比例选项

linux - 每个函数加载的 glibc 基地址不同

linux - 如何在 bash 中附加两个文件

c - 需要改变独立流的体积

java - 通过Android App从本地Wifi接收数据并使用3G实时传输到远程服务器

java - 启动 Cassandra 3.4 时出错

linux - 模拟非登录用户的权限

java - 从 shell 文件创建批处理文件

linux - shell脚本中的su命令