我正在寻找一个终端命令,可以将该音量设置为50%,这样我可以在登录时运行它,而不必担心如果我忘记调低音量,第一次播放的音频会突然大声响起。有哪些命令可以更改那个音量,即声音指示器中的音量?
我已经在gsettings和dbus中查找过,但是没有找到任何可以让我像那样设置系统音量的东西。我知道alsamixer,但那不是我要找的解决方案,因为它不允许我使用声音指示器或笔记本电脑的多媒体键来调节音量。
amixer -D pulse sset Master 5%+
amixer -D pulse sset Master 5%-
amixer -D pulse sset Master 50%
记住,这个命令允许你控制当前正在使用的任何声音设备上的参数。If you are using ALSA, amixer can be helpful for your script programming.
When dropping the
amixer --help
command in a terminal you will see something like this:
Depending on your soundcard, levels may be different than mine, but you can use
alsamixer
in the terminal in order to check which levels and which features in your sound card you can call in a command to set the volume as you wish.
In my example, with my principal sound card (I have 2: the embedded and a PCI audio card), levels are from 0 to 100, this way I can change the volume of a desired input/output in my soundcard by dropping in a terminal the next command:
amixer -c 0 set Front 50DB amixer -c 0 set Front 64DB
In the first command, the result will set the Front panel output to 78% level and the second one will set the Front panel output to 100% level.
In order to gather information related to your mixer controls, drop the
amixer
command with no parameters and you will get a list. Or indicate which audio device you wish to see a list of controls withamixer -c X
(where "X" is the number of your audio device).BTW: Remember that DB values are calculated logarithmically and not linearly.
alsamixer
上按下F6
,在amixer
上使用--card n
来更改声卡。 - Pooyan Khosraviamixer
命令会随机改变我的扬声器/耳机的平衡(左/右),而使用pactl
和@DEFAULT_SINK@
则没有问题。 - exicpactl
时遇到了相同的行为。而pavucontrol
可以通过图形界面让我们看到它的效果如何。 - Geppettvs D'Constanzopactl set-sink-volume @DEFAULT_SINK@ +10%
pactl set-sink-volume @DEFAULT_SINK@ -10%
pactl set-sink-volume @DEFAULT_SINK@ 50%
pactl set-sink-volume @DEFAULT_SINK@ 150%
pactl
/pacmd
(与amixer
不同)允许将音量增加到100%以上 :-)。@DEFAULT_SINK@
作为接收器,而不是使用数字0
。您可以使用pactl set-default-sink my-sink-name
来设置默认接收器(使用pactl list short sinks
列出名称)。 - pevik0
之外的接收器。可以使用pactl list short sinks
的第一个数字。例如,以下命令有效:pactl set-sink-volume $(pactl list short sinks | head -n1 | cut -f1) 50%
- ideasman42增大音量:pactl set-sink-volume @DEFAULT_SINK@ +1000
降低音量:pactl set-sink-volume @DEFAULT_SINK@ -1000
静音:pactl set-sink-mute @DEFAULT_SINK@ toggle
您可以使用以下值来控制音量:
<number>
+<number>
-<number>
示例:
pactl set-sink-volume @DEFAULT_SINK@ 50000
将将音量设置为大约 76%
<数字>.<数字>
增加:+<数字>.<数字>
减少:-<数字>.<数字>
示例:
pactl set-sink-volume @DEFAULT_SINK@ 0.44\
将音量设置为大约76%<数字>%
增加:+<数字>%
减少:-<数字>%
示例:
pactl set-sink-volume @DEFAULT_SINK@ 76%
将音量设置为大约76%<number>dB
+<number>dB
-<number>dB
示例:
pactl set-sink-volume @DEFAULT_SINK@ 0.0dB
将音量设置为100%
amixer set 'Master' 10%+
- 增加最大音量10%
amixer set 'Master' 10%-
- 减少最大音量10%
amixer set 'Master' 10%
- 获得最大音量的10%
amixer set 'Master' 80%
- 获得最大音量的80%
.. 等等。
如果您想将音量设置为除了'Master'之外的其他选项,请通过以下方式查看列表:
amixer scontrols
alsamixer
和 pacmd
。