mil*_*epa 23 command-line scripting arch-linux volume
我在平铺窗口管理器上有一个文本状态栏,我正在使用 tcl 向它提供信息。目前我需要一个命令行来输出 0% 到 100% 的音量级别。我正在使用 Arch Linux。
jas*_*yan 22
amixer
在状态栏中解析音量输出的单行:
awk -F"[][]" '/dB/ { print $2 }' <(amixer sget Master)
Run Code Online (Sandbox Code Playgroud)
编辑: 截至 2020 年 11 月,Arch Linux 的更新混合器为 1.2.4,输出中没有“dB”。因此,该命令应替换为:
awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master)
Run Code Online (Sandbox Code Playgroud)
slm*_*slm 16
您可以使用它amixer
来执行此操作。
$ amixer get Master
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 65536 [100%] [off]
Front Right: Playback 65536 [100%] [off]
Run Code Online (Sandbox Code Playgroud)
您也可以像这样更改它并将其静音:
设置音量 75%
$ amixer set Master 75%
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 49152 [75%] [on]
Front Right: Playback 49152 [75%] [on]
Run Code Online (Sandbox Code Playgroud)
静音/取消静音
$ amixer set Master toggle
Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 65536
Mono:
Front Left: Playback 65536 [100%] [on]
Front Right: Playback 65536 [100%] [on]
Run Code Online (Sandbox Code Playgroud)
如果您不想通过--quiet
开关看到任何输出,则可以将输出静音。
$ amixer --quiet set Master 75%
$
Run Code Online (Sandbox Code Playgroud)
对
amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }'
85%
Run Code Online (Sandbox Code Playgroud)
剩下
amixer sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }'
85%
Run Code Online (Sandbox Code Playgroud)
声音服务器
如果您没有默认使用pulseaudio,您可以指定amixer
要使用的服务器-D pulse
amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }'
85%
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
51608 次 |
最近记录: |