Skip to content

Commit 045eed8

Browse files
authored
Merge pull request #623 from 4hnme/cam-filter
privacy-indicator: add camera filter regex
2 parents c13e2fb + 319d1ba commit 045eed8

5 files changed

Lines changed: 45 additions & 11 deletions

File tree

privacy-indicator/Main.qml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Item {
3131
property bool enableToast: cfg.enableToast ?? defaults.enableToast ?? true
3232
property string activeColorKey: cfg.activeColor ?? defaults.activeColor ?? "primary"
3333
property string micFilterRegex: cfg.micFilterRegex ?? defaults.micFilterRegex ?? ""
34+
property string camFilterRegex: cfg.camFilterRegex ?? defaults.camFilterRegex ?? ""
3435

3536
PwObjectTracker {
3637
objects: Pipewire.ready ? Pipewire.nodes.values : []
@@ -44,8 +45,25 @@ Item {
4445
onStreamFinished: {
4546
var appsString = this.text.trim();
4647
var apps = appsString.length > 0 ? appsString.split(',') : [];
47-
root.camApps = apps;
48-
root.camActive = apps.length > 0;
48+
49+
var filterRegex = null;
50+
if (root.camFilterRegex && root.camFilterRegex.length > 0) {
51+
try {
52+
filterRegex = new RegExp(root.camFilterRegex);
53+
} catch (e) {
54+
Logger.w("PrivacyIndicator: Invalid camFilterRegex:", root.camFilterRegex);
55+
}
56+
}
57+
58+
var appNames = [];
59+
for (var i = 0; i < apps.length; i++) {
60+
appName = apps[i];
61+
if (filterRegex && appName && filterRegex.test(appName)) continue;
62+
if (appName && appNames.indexOf(appName) === -1) appNames.push(appName);
63+
}
64+
65+
root.camApps = appNames;
66+
root.camActive = appNames.length > 0;
4967
}
5068
}
5169
}
@@ -265,15 +283,15 @@ Item {
265283
property bool oldMicActive: false
266284
onMicActiveChanged: {
267285
if (enableToast && micActive && !oldMicActive) {
268-
ToastService.showNotice(pluginApi?.tr("toast.mic-on") || "Microphone is active", "", "microphone");
286+
ToastService.showNotice(pluginApi?.tr("toast.mic-on"), "", "microphone");
269287
}
270288
oldMicActive = micActive
271289
}
272290

273291
property bool oldCamActive: false
274292
onCamActiveChanged: {
275293
if (enableToast && camActive && !oldCamActive) {
276-
ToastService.showNotice(pluginApi?.tr("toast.cam-on") || "Camera is active", "", "camera");
294+
ToastService.showNotice(pluginApi?.tr("toast.cam-on"), "", "camera");
277295
}
278296
oldCamActive = camActive
279297
}
@@ -285,7 +303,7 @@ Item {
285303
property bool oldScrActive: false
286304
onScrActiveChanged: {
287305
if (enableToast && scrActive && !oldScrActive) {
288-
ToastService.showNotice(pluginApi?.tr("toast.screen-on") || "Screen sharing is active", "", "screen-share");
306+
ToastService.showNotice(pluginApi?.tr("toast.screen-on"), "", "screen-share");
289307
}
290308
oldScrActive = scrActive
291309
}

privacy-indicator/Panel.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Item {
1616
property real contentPreferredHeight: 450 * Style.uiScaleRatio
1717

1818
readonly property var mainInstance: pluginApi?.mainInstance
19+
readonly property bool allowAttach: true
1920

2021
Rectangle {
2122
id: panelContainer
@@ -46,7 +47,7 @@ Item {
4647

4748
NText {
4849
Layout.fillWidth: true
49-
text: pluginApi?.tr("history.title") || "Access History"
50+
text: pluginApi?.tr("history.title")
5051
font.weight: Style.fontWeightBold
5152
pointSize: Style.fontSizeL
5253
color: Color.mOnSurface
@@ -154,7 +155,7 @@ Item {
154155
NText {
155156
Layout.alignment: Qt.AlignHCenter
156157
visible: (!mainInstance || mainInstance.accessHistory.length === 0)
157-
text: pluginApi?.tr("history.empty") || "No recent access"
158+
text: pluginApi?.tr("history.empty")
158159
color: Qt.alpha(Color.mOnSurface, 0.5)
159160
pointSize: Style.fontSizeM
160161
Layout.topMargin: Style.marginL

privacy-indicator/Settings.qml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ColumnLayout {
1818
property string activeColor: cfg.activeColor ?? defaults.activeColor ?? "primary"
1919
property string inactiveColor: cfg.inactiveColor ?? defaults.inactiveColor ?? "none"
2020
property string micFilterRegex: cfg.micFilterRegex ?? defaults.micFilterRegex
21+
property string camFilterRegex: cfg.camFilterRegex ?? defaults.camFilterRegex
2122

2223
spacing: Style.marginL
2324

@@ -102,12 +103,21 @@ ColumnLayout {
102103

103104
NTextInput {
104105
Layout.fillWidth: true
105-
label: pluginApi?.tr("settings.micFilterRegex.label") || "Microphone filter regex"
106-
description: pluginApi?.tr("settings.micFilterRegex.desc") || "Regex pattern to filter out microphone applications"
106+
label: pluginApi?.tr("settings.micFilterRegex.label")
107+
description: pluginApi?.tr("settings.micFilterRegex.desc")
107108
placeholderText: "effect_input.rnnoise|easyeffects"
108109
text: root.micFilterRegex
109110
onTextChanged: root.micFilterRegex = text
110111
}
112+
113+
NTextInput {
114+
Layout.fillWidth: true
115+
label: pluginApi?.tr("settings.camFilterRegex.label")
116+
description: pluginApi?.tr("settings.camFilterRegex.desc")
117+
placeholderText: "droidcam"
118+
text: root.camFilterRegex
119+
onTextChanged: root.camFilterRegex = text
120+
}
111121
}
112122

113123
function saveSettings() {

privacy-indicator/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
"micFilterRegex": {
3131
"desc": "Regex pattern to filter out microphone applications. Matching apps are completely excluded from detection.",
3232
"label": "Microphone filter regex"
33+
},
34+
"camFilterRegex": {
35+
"desc": "Regex pattern to filter out camera applications. Matching apps are completely excluded from detection.",
36+
"label": "Camera filter regex"
3337
}
3438
},
3539
"tooltip": {
@@ -51,4 +55,4 @@
5155
"stopped": "Stopped"
5256
}
5357
}
54-
}
58+
}

privacy-indicator/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"iconSpacing": 4,
3131
"activeColor": "primary",
3232
"inactiveColor": "none",
33-
"micFilterRegex": ""
33+
"micFilterRegex": "",
34+
"camFilterRegex": ""
3435
}
3536
}
3637
}

0 commit comments

Comments
 (0)