pulseaudio: add target option to control source (microphone) volume

The pulseaudio/slider module had partial support for a "target" config
option but changeVolume() in the audio backend was hardcoded to only
modify sink volume. This adds full source volume control:

- Add AudioTarget enum (Sink/Source) to audio_backend
- Extend changeVolume() overloads with AudioTarget parameter
- Store and use pa_cvolume for source (with mono channel default)
- Add sourceVolumeModifyCb for source volume change confirmation
- Add "target" config option to the pulseaudio module for scroll control
- Document "target" in both pulseaudio and pulseaudio-slider man pages

Usage:
  "pulseaudio/slider#in": { "target": "source" }
  "pulseaudio#in": { "target": "source" }
This commit is contained in:
7FM
2026-03-06 00:41:42 +01:00
parent 68d4360c26
commit ab5b1a6cd4
8 changed files with 116 additions and 43 deletions
+5 -1
View File
@@ -7,6 +7,10 @@ waybar::modules::Pulseaudio::Pulseaudio(const std::string& id, const Json::Value
backend = util::AudioBackend::getInstance([this] { this->dp.emit(); });
backend->setIgnoredSinks(config_["ignored-sinks"]);
if (config_["target"].isString() && config_["target"].asString() == "source") {
target = util::AudioTarget::Source;
}
}
bool waybar::modules::Pulseaudio::handleScroll(GdkEventScroll* e) {
@@ -33,7 +37,7 @@ bool waybar::modules::Pulseaudio::handleScroll(GdkEventScroll* e) {
? util::ChangeType::Increase
: util::ChangeType::Decrease;
backend->changeVolume(change_type, step, max_volume);
backend->changeVolume(change_type, step, max_volume, target);
return true;
}