gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:35:06 26 4
gpt4 key购买 nike

我想知道如何使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com