我经常在工作时播放新闻,并想在广告期间静音,所以四处寻找并找到了这个
这产生了一些好东西,并产生了以下脚本,它的作用就像一个魅力:#!/bin/bash
#Mute, wait, unmute: attempt 1
for x in `amixer controls | grep layback` ; do
amixer cset "${x}" on ; done
echo Mute for how many seconds?
read v1
sleep $v1
for x in `amixer controls | grep layback` ; do
amixer cset "${x}" 700% ; done
哪个有效,但在终端屏幕上导致一团糟:(只是一个味道)
<p>161 [~]$ MM<br>
numid=16,iface=MIXER,name='Master Playback Switch'<br>
; type=BOOLEAN,access=rw------,values=1<br>
: values=on<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Switch'<br>
numid=15,iface=MIXER,name='Master Playback Volume'<br>
; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0<br>
: values=0<br>
| dBscale-min=-95.25dB,step=0.75dB,mute=1<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Volume'<br>...etc</p>
通过在 cset 之后添加 -q 来清理一下
<p>166 [~]$ MM<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Switch'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Volume'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Switch'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Volume'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Volume'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Switch'<br>
Wrong control identifier: Playback<br>
Wrong control identifier: Volume'<br>
amixer: Control default element write error: Operation not
permitted<br>...etc</p>
但是为什么我会收到所有这些“错误的控制标识符”消息?
我试过,man grep
但后来我的头掉了下来,我不得不重新贴上它,现在我头疼了。我饿了。
每一次欢呼
试试这个:
read -p "Mute for how many seconds? " v1 ; \
amixer controls | grep layback | grep -v ' Ma' |
xargs -I '{}' amixer -q cset '{}' on ; \
sleep $v1 ; \
amixer controls | grep layback | grep -v ' Ma' |
xargs -I '{}' amixer -q cset '{}' 700%
笔记:
amixer
选项不兼容。使用grep -v
过滤掉那些混频器可以解决这个问题。read
优先通行,否则静音持续输入秒加上所花费的时间用户输入他们。xargs
在这里并不是真的有必要,但它似乎比使用带有变量的循环更简单。; \
s 可以更轻松地一次性复制和粘贴到命令行。在脚本; \
中不需要行尾。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句