pulseaudio: Add 'sink-mapping' config option
This commit adds a new optional config to the pulseaudio modules. It
maps sink names to other sink names so that if the current sink is a
key, the sink named by the value is considered to be the current sink
instead of it.
E.g.
"sink-mapping": {
"easyeffects_sink": "speakers_sink"
}
This commit is contained in:
@@ -155,6 +155,13 @@ void AudioBackend::sinkInfoCb(pa_context * /*context*/, const pa_sink_info *i, i
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto mapping = backend->sink_mapping_.find(backend->current_sink_name_);
|
||||
mapping != backend->sink_mapping_.end()) {
|
||||
if (i->name == mapping->second) {
|
||||
backend->current_sink_name_ = i->name;
|
||||
}
|
||||
}
|
||||
|
||||
if (backend->current_sink_name_ == i->name) {
|
||||
backend->current_sink_running_ = i->state == PA_SINK_RUNNING;
|
||||
}
|
||||
@@ -292,4 +299,14 @@ void AudioBackend::setIgnoredSinks(const Json::Value &config) {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioBackend::setSinkMapping(const Json::Value &config) {
|
||||
if (config.isObject()) {
|
||||
for (auto it = config.begin(); it != config.end(); ++it) {
|
||||
if (it.key().isString() && it->isString()) {
|
||||
sink_mapping_.emplace(it.key().asString(), it->asString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace waybar::util
|
||||
|
||||
Reference in New Issue
Block a user