Merge pull request #4173 from S0nter/master
privacy: ignore some streams
This commit is contained in:
@ -31,6 +31,8 @@ class Privacy : public AModule {
|
|||||||
uint iconSpacing = 4;
|
uint iconSpacing = 4;
|
||||||
uint iconSize = 20;
|
uint iconSize = 20;
|
||||||
uint transition_duration = 250;
|
uint transition_duration = 250;
|
||||||
|
std::set<std::pair<PrivacyNodeType, std::string>> ignore;
|
||||||
|
bool ignore_monitor = true;
|
||||||
|
|
||||||
std::shared_ptr<util::PipewireBackend::PipewireBackend> backend = nullptr;
|
std::shared_ptr<util::PipewireBackend::PipewireBackend> backend = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -25,6 +25,7 @@ class PrivacyNodeInfo {
|
|||||||
std::string media_name;
|
std::string media_name;
|
||||||
std::string node_name;
|
std::string node_name;
|
||||||
std::string application_name;
|
std::string application_name;
|
||||||
|
bool is_monitor = false;
|
||||||
|
|
||||||
std::string pipewire_access_portal_app_id;
|
std::string pipewire_access_portal_app_id;
|
||||||
std::string application_icon_name;
|
std::string application_icon_name;
|
||||||
|
@ -37,6 +37,17 @@ the screen or playing audio.
|
|||||||
default: false ++
|
default: false ++
|
||||||
Enables this module to consume all left over space dynamically.
|
Enables this module to consume all left over space dynamically.
|
||||||
|
|
||||||
|
*ignore-monitor* ++
|
||||||
|
typeof: bool ++
|
||||||
|
default: true ++
|
||||||
|
Ignore streams with *stream.monitor* property.
|
||||||
|
|
||||||
|
*ignore* ++
|
||||||
|
typeof: array of objects ++
|
||||||
|
default: [] ++
|
||||||
|
Additional streams to be ignored. See *IGNORE CONFIGURATION* for++
|
||||||
|
more information.
|
||||||
|
|
||||||
# MODULES CONFIGURATION
|
# MODULES CONFIGURATION
|
||||||
|
|
||||||
*type*: ++
|
*type*: ++
|
||||||
@ -54,6 +65,14 @@ the screen or playing audio.
|
|||||||
default: 24 ++
|
default: 24 ++
|
||||||
The size of each icon in the tooltip.
|
The size of each icon in the tooltip.
|
||||||
|
|
||||||
|
# IGNORE CONFIGURATION
|
||||||
|
|
||||||
|
*type*: ++
|
||||||
|
typeof: string
|
||||||
|
|
||||||
|
*name*: ++
|
||||||
|
typeof: string
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -77,6 +96,17 @@ the screen or playing audio.
|
|||||||
"tooltip": true,
|
"tooltip": true,
|
||||||
"tooltip-icon-size": 24
|
"tooltip-icon-size": 24
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"ignore-monitor": true,
|
||||||
|
"ignore": [
|
||||||
|
{
|
||||||
|
"type": "audio-in",
|
||||||
|
"name": "cava"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "screenshare",
|
||||||
|
"name": "obs"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
@ -74,6 +74,24 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, Gtk::Orientat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& ignore_item : config_["ignore"]) {
|
||||||
|
if (!ignore_item.isObject() || !ignore_item["type"].isString() ||
|
||||||
|
!ignore_item["name"].isString())
|
||||||
|
continue;
|
||||||
|
const std::string type = ignore_item["type"].asString();
|
||||||
|
const std::string name = ignore_item["name"].asString();
|
||||||
|
|
||||||
|
auto iter = typeMap.find(type);
|
||||||
|
if (iter != typeMap.end()) {
|
||||||
|
auto& [_, nodeType] = iter->second;
|
||||||
|
ignore.emplace(nodeType, std::move(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config_["ignore-monitor"].isBool()) {
|
||||||
|
ignore_monitor = config_["ignore-monitor"].asBool();
|
||||||
|
}
|
||||||
|
|
||||||
backend = util::PipewireBackend::PipewireBackend::getInstance();
|
backend = util::PipewireBackend::PipewireBackend::getInstance();
|
||||||
backend->privacy_nodes_changed_signal_event.connect(
|
backend->privacy_nodes_changed_signal_event.connect(
|
||||||
sigc::mem_fun(*this, &Privacy::onPrivacyNodesChanged));
|
sigc::mem_fun(*this, &Privacy::onPrivacyNodesChanged));
|
||||||
@ -88,6 +106,11 @@ void Privacy::onPrivacyNodesChanged() {
|
|||||||
nodes_screenshare.clear();
|
nodes_screenshare.clear();
|
||||||
|
|
||||||
for (auto& node : backend->privacy_nodes) {
|
for (auto& node : backend->privacy_nodes) {
|
||||||
|
if (ignore_monitor && node.second->is_monitor) continue;
|
||||||
|
|
||||||
|
auto iter = ignore.find(std::pair(node.second->type, node.second->node_name));
|
||||||
|
if (iter != ignore.end()) continue;
|
||||||
|
|
||||||
switch (node.second->state) {
|
switch (node.second->state) {
|
||||||
case PW_NODE_STATE_RUNNING:
|
case PW_NODE_STATE_RUNNING:
|
||||||
switch (node.second->type) {
|
switch (node.second->type) {
|
||||||
|
@ -49,6 +49,8 @@ void PrivacyNodeInfo::handleNodeEventInfo(const struct pw_node_info *info) {
|
|||||||
pipewire_access_portal_app_id = item->value;
|
pipewire_access_portal_app_id = item->value;
|
||||||
} else if (strcmp(item->key, PW_KEY_APP_ICON_NAME) == 0) {
|
} else if (strcmp(item->key, PW_KEY_APP_ICON_NAME) == 0) {
|
||||||
application_icon_name = item->value;
|
application_icon_name = item->value;
|
||||||
|
} else if (strcmp(item->key, "stream.monitor") == 0) {
|
||||||
|
is_monitor = strcmp(item->value, "true") == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user