linux终端声音设置,终端命令设置音量?

这篇博客讨论了如何通过终端命令在Linux系统中调整音量,特别是在启动时将音量设置为特定值。提到了amixer和PulseAudio的命令行工具,如amixer-Dpulse setMaster 50%用于设置音量为50%,而pactl set-sink-volume 0 50%也可达到同样效果。此外,还提供了其他命令行选项来增加、减少或获取音量状态。
摘要由CSDN通过智能技术生成

问题描述

我有一个外部声卡,大部分工作正常,除了第一次插入时或打开笔记本电脑时,音量设置为100%。也就是整个系统音量,如声音指示器所示。

我正在寻找的是一个终端命令,将该音量设置为50%,这样我就可以在登录时运行它,而不必担心如果我忘记了转动,我播放的第一个音频会在我身上发出声音音量降低。哪些命令允许您更改该音量,即声音指示器中的音量?

我用gsettings和dbus四处探索,但一直无法找到任何可以让我设置系统音量的东西。我知道alsamixer,但这不是我正在寻找的解决方案,因为这不允许我使用声音指示器或笔记本电脑的多媒体键来改变音量。

最佳解决方法

将音量提高5%

amixer -D pulse sset Master 5%+

减少5%

amixer -D pulse sset Master 5%-

将音量设置为50%

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:

68ba69b00708e7a421ce466477f9877a.png

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.

7d6c7e34c548f78bd2cddc6149721ad4.png

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 with amixer -c X (where “X” is the number of your audio device).

BTW: Remember that DB values are calculated logarithmically and not linearly.

请记住,该命令允许您控制当前使用的任何声音设备上的参数。

祝你好运!

次佳解决方法

你可以用PulseAudio本身来做(我不会推荐使用ALSA,因为那时你不能使用GUI来增加/减少音量)。

使用pactl:您可以按如下方式设置特定设备的卷:

pactl set-sink-volume 0 +10%

这使得音量增加10%。如果你想把它降低10%

pactl set-sink-volume 0 -10%

如果你需要50%的音量:

pactl set-sink-volume 0 50%

如果你需要摇动整个地方:

pactl set-sink-volume 0 150%

你可以使用百分数或整数,但整数很慢,可能不是你的东西。

pactl /pacmd(与amixer不同)允许将音量增加超过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

参考资料

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值