如何在终端中获取当前扬声器输出音量级别?

如何在终端中获取当前扬声器输出音量级别?

例如,我有一个打开的浏览器,其中包含 YouTube 或其他播放音频的程序,并且希望获取当前音频级别(0-100% 之间的数字)。更准确地说,我已经看到了带有显示系统中设置的音频级别的命令的答案,但我想查看来自播放音频的应用程序的音频级别。

答案1

如果您的系统使用脉冲音频,您可以使用 pacmd 列出正在播放的应用程序

这里只有firefox在播放,音量为54%:

hoov@hal:~$ pacmd list-sink-inputs 
1 sink input(s) available.
    index: 4577
        driver: <protocol-native.c>
        flags: START_CORKED 
        state: RUNNING
        sink: 0 <alsa_output.pci-0000_00_1b.0.analog-stereo>
        volume: front-left: 35578 /  54% / -15,92 dB,   front-right: 35578 /  54% / -15,92 dB
                balance 0,00
        muted: no
        current latency: 89,62 ms
        requested latency: 75,00 ms
        sample spec: float32le 2ch 48000Hz
        channel map: front-left,front-right
                     Stereo
        resample method: speex-float-1
        module: 14
        client: 840 <Firefox>
        properties:
                media.name = "AudioStream"
                application.name = "Firefox"
                native-protocol.peer = "UNIX socket client"
                native-protocol.version = "33"
                application.process.id = "11744"
                application.process.user = "gobuki"
                application.process.host = "morpheus"
                application.process.binary = "firefox"
                application.language = "en_US.UTF-8"
                window.x11.display = ":0"
                application.process.machine_id = "0f06bccf24c24ae5ba5d40c54b7d8f58"
                application.process.session_id = "2"
                application.icon_name = "firefox"
                module-stream-restore.id = "sink-input-by-application-name:Firefox"

相关内容