是否可以通过终端而不是单击顶部栏中的扬声器图标来设置音频音量?我发现拿到鼠标很烦人。

评论

读取主音量水平,以百分比百分比0%-100%表示:混合器sget Master | grep'权利:'| awk -F'[] []''{print $ 2}'将主音量提高10%:混合器-q sset Master 10%+

#1 楼

对于交互式用法,您可以使用alsamixer。对于脚本编写(例如,绑定到组合键),请查看amixer

大多数系统默认包括alsamixer。 :

# Gets a list of simple mixer controls
$ amixer scontrols 


然后将其设置为所需的音量,例如

$ amixer sset 'Master' 50%


评论


“ sset”和“ set”之间有什么区别。 (我都尝试过,而且都可行)

– Venryx
17年12月6日在21:39

@Venryx混音器建议它们是等效的,并且“ sset”中的“ s”代表“ simple”。还有一个“ cset”,用于设置卡控制内容。

–马特西亚斯·布劳恩(Matthias Braun)
'18 -10-7在13:25

在我的.bashrc中添加了以下内容,以使此命令更容易:volume(){amixer sset'Master'$ 1%; }

– Philip Kirkbride
20-1-24的16:21

#2 楼

在Openbox的配置文件rc.xml中可以找到:

# increase by 3%
amixer -q sset Master 3%+

# decrease by 3%
amixer -q sset Master 3%-

# mute/unmute
amixer -q sset Master toggle


amixer手册页可以提供更多详细信息。

#3 楼

如果系统使用的是pulseaudio,则可以使用pactl

pactl set-sink-volume 0 +15%




pactl set-sink-volume 0 -5dB


指定整数或线性因子:

set-sink-volume SINK VOLUME [VOLUME ...]
          Set the volume of the specified sink (identified by its symbolic name or numerical index). VOLUME can be speci‐
          fied as an integer (e.g. 2000, 16384), a linear factor (e.g. 0.4, 1.100), a percentage (e.g. 10%, 100%) or a
          decibel value (e.g. 0dB, 20dB). If the volume specification start with a + or - the volume  adjustment  will  be
          relative to the current sink volume. A single volume value affects all channels; if multiple volume values are
          given their number has to match the sink's number of channels.


评论


来自arch linux Wiki的说明:带有负百分比参数的pactl命令将失败,并显示“无效选项”错误。使用标准的shell-伪参数禁用负参数之前的参数解析。例如pactl set-sink-volume 1--5%

–杰米·科克本(Jamie Cockburn)
15年8月25日在8:01

@JamieCockburn-我不确定是什么时候写的,但是我使用archlinux,而且绝对不需要附加值-带有负值(百分比,db,整数...它们都可以正常工作)。实际上,情况恰恰相反:如果我使用-例如wiki pactl set-sink-volume 1--3%我得到无效的体积规格。

–don_crissti
2015年8月25日在10:02



那一定要依赖shell吗?我在使用Xfce的ubuntu 14.04上,并从bash(4.3.11)运行命令。如果省略-,我将得到一个无效的选项。

–杰米·科克本(Jamie Cockburn)
15年8月25日在10:58

@JamieCockburn-我认为外壳不相关(从记录来看,它对bash和zsh都适用)。 pactl的早期版本可能存在此问题,并且上游很可能已解决了该问题(我使用的是6.0版)。

–don_crissti
15年8月25日在11:08

@JamieCockburn我正在运行ubuntu 16.04 xfce bash,它的工作原理很完美,没有“-”,仅需注意。

– Reishin
16年2月15日在15:47

#4 楼

我知道这是一个古老的。由于Alsa和Pulseaudio如此连接,askubuntu的这个回答帮助我从主声音和HDMI上管理音量: br减小音量

amixer -q -D pulse sset Master 10%+


切换静音

amixer -q -D pulse sset Master 10%-


其他混音器设置命令也可以使用。

#5 楼

这些“对于人耳来说更自然”。

要获得alsamixer单元中的母版,请使用:

amixer -M get Master


例如,将alsamixer单元中的音量提高5% :

amixer -M set Master 5%+


https://bbs.archlinux.org/viewtopic.php?id=135348

#6 楼

在OS X中,请使用以下命令:

# highest
osascript -e "set Volume 7"
# lowest
osascript -e "set Volume 1"
# middle
osascript -e "set Volume 3.5"  


您甚至可以将音量设置为其他分数级别:

# 25%
osascript -e "set Volume 1.75"


评论


值得注意的是,您还可以使用Mac的音量按钮以小数增量更改音量。

–通配符
16年2月17日在8:04

@Wildcard Mac音量按钮仅以0.25为增量

– 1英寸
2016年9月7日在2:35

#7 楼

您也可以尝试pamixer,它是一个完全可以满足您需求的最新项目。它在ArchLinux AUR存储库中具有相同的名称。

评论


现在甚至在社区存储库中

– Michal Polovka
18年11月7日在22:33