从 CLI 在 Linux 中静音音频的脚本有效,但需要帮助

一切安好

我经常在工作时播放新闻,并想在广告期间静音,所以四处寻找并找到了这个

堆栈溢出线程

这产生了一些好东西,并产生了以下脚本,它的作用就像一个魅力:

#!/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但后来我的头掉了下来,我不得不重新贴上它,现在我头疼了。我饿了。

每一次欢呼

agc

试试这个:

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% 

笔记:

  1. 主要的问题似乎是像“Playback Con Mask”“Playback Channel Map”这样混音器amixer选项不兼容使用grep -v过滤掉那些混频器可以解决这个问题。
  2. read优先通行,否则静音持续输入秒加上所花费的时间用户输入他们。
  3. xargs 在这里并不是真的有必要,但它似乎比使用带有变量的循环更简单。
  4. 这些; \s 可以更轻松地一次性复制和粘贴到命令行。在脚本; \中不需要行尾。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在Linux Ubuntu中安装@ vue / cli

如何使bash脚本知道在Linux中执行的CLI程序的输出?

awk 脚本中拒绝了有效的 linux 命令

从CLI启动Linux桌面

如何从Linux CLI读取/写入所有BIOS设置?

Linux-在CLI中更改主机名

删除文件中包含字符串的文件-Linux CLI

如何在Linux RHEL中安装特定版本的Azure CLI

在 linux mint 中安装 firebase cli 时出现错误

通过Linux上的CLI禁用Chrome Beta中的JavaScript

Linux。为什么我的 Linux 命令在终端上有效,但在脚本中无效

如何在 Linux 中创建有效的 WHOIS 脚本

Linux CLI时间戳解析

从CLI调用时,脚本中的Trap命令有效,但在PBS作业中使用时,则不起作用

在更老的linux联机帮助页(如traceroute)中修复内容的最有效方法是什么?

我需要一个Powershell脚本/ CLI / API,它可以计算在Azure订阅上运行的所有VM(Windows和Linux)的运行(维护)时间。

尝试为Linux中的某些CLI命令设置没有密码的问题

如何使用Linux CLI查找代码行并仅从特定/目录中的所有文件删除该行

如何将CLI Linux转换为GUI?或者至少如何在CLI linux中运行像Firefox这样的gui应用程序?正在安装x窗口系统?

使用脚本将字符串传递给linux cli交互式程序

如何在 Linux 中使用 bash 脚本运行 WP-CLI

Linux CLI查找没有子目录的目录路径-结果是仅父目录路径

在Linux中使用CLI更改文件夹中所有文件扩展名

是否有Linux CLI工具来确定分区的“已用”空间?(如gparted)

cli输入中c中的Linux文件I / O分段错误

无法使用Linux子系统中的Azure CLI在Azure VM上执行“自定义脚本扩展”

如何在Linux上的xampp安装中访问mysql和php cli?

如何在RedHat 8中的Linux CLI上转到mysql数据库主机

无法使用npm在Linux Mint 17中安装Mean-cli