mpris: Rename dynamic-priority to dynamic-importance-order keeping backward compatibility

This commit is contained in:
Erik Rodriguez 2023-06-03 10:43:12 -03:00
parent 77a8420aaf
commit 66ce74d29b
No known key found for this signature in database
GPG Key ID: 5979ED35ED299E6D
2 changed files with 11 additions and 9 deletions

View File

@ -80,11 +80,12 @@ The *mpris* module displays currently playing media via libplayerctl.
declaration of the first among the two tags. Absence in this list means ++
force exclusion.
*dynamic-priority*: ++
*dynamic-importance-order*: ++
typeof: []string ++
default: ["title", "length", "position", "artist", "album"] ++
Priority of the tags when truncating the Dynamic tag (absence in this
list means force inclusion).
default: ["title", "artist", "album", "position", "length"] ++
Priority of the tags when truncating the Dynamic tag. The final ones ++
will be the first to be truncated. Absence in this list means force ++
inclusion.
*dynamic-separator*: ++
typeof: string ++

View File

@ -79,12 +79,13 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
if (config["dynamic-len"].isUInt()) {
dynamic_len_ = config["dynamic-len"].asUInt();
}
if (config_["dynamic-priority"].isArray()) {
// "dynamic-priority" has been kept for backward compatibility
if (config_["dynamic-importance-order"].isArray() || config_["dynamic-priority"].isArray()) {
dynamic_prio_.clear();
for (auto it = config_["dynamic-priority"].begin(); it != config_["dynamic-priority"].end();
++it) {
if (it->isString()) {
dynamic_prio_.push_back(it->asString());
const auto& dynamic_priority = config_["dynamic-importance-order"].isArray() ? config_["dynamic-importance-order"] : config_["dynamic-priority"];
for (const auto& value : dynamic_priority) {
if (value.isString()) {
dynamic_prio_.push_back(value.asString());
}
}
}