This module provides a Py3status integration to manage and display audio information for the current audio output device. It uses pactl
(PulseAudio Control) and amixer
commands to interact with PulseAudio sinks and control audio settings.
- Displays the current audio output device, its volume, and mute status.
- Allows cycling through multiple audio output devices.
- Supports custom aliases for audio output device names.
- Handles mouse click events for:
- Toggling mute/unmute.
- Adjusting volume (increase/decrease).
- Switching between audio output devices.
pactl
: Command-line tool for interacting with PulseAudio.amixer
: Command-line mixer for ALSA soundcard driver.
- This script is designed to be used as a Py3status module.
- Clone or download this repository.
- Place the
audio.py
file in your Py3status configuration folder, typically located at~/.config/i3status/py3status/
. - Add the module to your i3status configuration:
order += "audio"
- Optionally, configure the module parameters like this:
audio { volume_step = 5 output_aliases = " bluez_output.84_AC_60_29_EE_08.1:🎧, alsa_output.pci-0000_00_1f.3.analog-stereo:🔊 " }
The following options can be configured in the Py3status module:
Option | Type | Default Value | Description |
---|---|---|---|
output_aliases |
str |
"" |
A string to define custom aliases for audio output devices. |
muted_color |
str |
"#FF0000" |
The color to display when the audio output is muted. |
volume_step |
int |
1 |
The percentage step to increase or decrease the volume. |
interval |
float |
0.1 |
The refresh interval for the module, in seconds. |
You can provide aliases for audio outputs to display friendly names or icons. For example:
output_aliases = "
bluez_output.84_AC_60_29_EE_08.1:🎧,
alsa_output.pci-0000_00_lf.3.analog-stereo:🔊
"
The audio()
method fetches and formats the current audio output information, including volume percentage and mute status. It automatically applies aliases if provided.
The on_click(event)
method allows interaction with the audio outputs using mouse buttons:
- Mute/Unmute: Left-click on the module to toggle mute/unmute.
- Change Output Device: Right-click to cycle through available audio outputs.
- Adjust Volume: Scroll up to increase volume or scroll down to decrease volume.
When displayed in i3bar, the module might show:
If you encounter issues with the module:
- Ensure
pactl
andamixer
are installed and accessible in your terminal. - Check that PulseAudio is running.
- Test the commands manually in the terminal:
pactl list sinks pactl info amixer -D pulse set Master mute
This module is licensed under the MIT License.
Contributions are welcome! Feel free to open issues or submit pull requests.