我试着在我的网络广播上做定制输出。(mpd/mpc)
getInfo.py:
#!/bin/bash
opt=$@
mpc $opt &> /dev/null
station="`mpc --format \"[%name%]\" | head -n 1`"
title="`mpc --format \"[%title%]\" | head -n 1`"
vol="`mpc | head -n 2 | tail -n 1 | awk {'print $4'}`"
echo $station
echo $title
echo "Volume: "${vol//[()_]/}并保存输出wach -n getInfo.py > radio.log
输出格式如下:
Amazing Smooth and Jazz
Koop - Koop Island Blues
Volume: 100%所以我需要每次当输出变化显示shell上的输出时。怎么做?
发布于 2014-01-07 13:32:58
为了让你开始:
#!/usr/bin/python3
from subprocess import Popen, PIPE
last_output = ""
while(1):
proc = Popen(["mpc"], stdout=PIPE)
output, retval = proc.communicate()
if not output == last_output:
print(output.decode('ascii'))
last_output = output我将把输出的微调留给你。
发布于 2015-12-02 11:11:55
如果您只希望在更改时更新歌曲输出,则mpc有一个命令current,它有一个--wait选项,它告诉mpc在显示结果之前一直阻塞到下一首歌曲,这允许您在它上循环。从那里你可以用它来更新你想要的任何软件。
例如:
while :; do notify-send --urgency=low -i "audio-headphones" "$(mpc current --wait)"; done &
https://stackoverflow.com/questions/20971847
复制相似问题