update
This commit is contained in:
@@ -10,7 +10,7 @@ Item {
|
||||
property var pluginApi: null
|
||||
|
||||
// --- Logic extracted from BarWidget.qml ---
|
||||
|
||||
|
||||
property bool micActive: false
|
||||
property bool camActive: false
|
||||
property bool scrActive: false
|
||||
@@ -19,7 +19,7 @@ Item {
|
||||
property var scrApps: []
|
||||
|
||||
property var accessHistory: []
|
||||
|
||||
|
||||
// Previous states for history tracking
|
||||
property var _prevMicApps: []
|
||||
property var _prevCamApps: []
|
||||
@@ -30,6 +30,7 @@ Item {
|
||||
property var defaults: pluginApi?.manifest?.metadata?.defaultSettings || ({})
|
||||
property bool enableToast: cfg.enableToast ?? defaults.enableToast ?? true
|
||||
property string activeColorKey: cfg.activeColor ?? defaults.activeColor ?? "primary"
|
||||
property string micFilterRegex: cfg.micFilterRegex ?? defaults.micFilterRegex ?? ""
|
||||
|
||||
PwObjectTracker {
|
||||
objects: Pipewire.ready ? Pipewire.nodes.values : []
|
||||
@@ -73,6 +74,16 @@ Item {
|
||||
function updateMicrophoneState(nodes, links) {
|
||||
var appNames = [];
|
||||
var isActive = false;
|
||||
|
||||
var filterRegex = null;
|
||||
if (root.micFilterRegex && root.micFilterRegex.length > 0) {
|
||||
try {
|
||||
filterRegex = new RegExp(root.micFilterRegex);
|
||||
} catch (e) {
|
||||
Logger.w("PrivacyIndicator: Invalid micFilterRegex:", root.micFilterRegex);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes[i];
|
||||
if (!node || !node.isStream || !node.audio || node.isSink) continue;
|
||||
@@ -80,8 +91,11 @@ Item {
|
||||
var mediaClass = node.properties["media.class"] || "";
|
||||
if (mediaClass === "Stream/Input/Audio") {
|
||||
if (node.properties["stream.capture.sink"] === "true") continue;
|
||||
isActive = true;
|
||||
|
||||
var appName = getAppName(node);
|
||||
if (filterRegex && appName && filterRegex.test(appName)) continue;
|
||||
|
||||
isActive = true;
|
||||
if (appName && appNames.indexOf(appName) === -1) appNames.push(appName);
|
||||
}
|
||||
}
|
||||
@@ -133,7 +147,7 @@ Item {
|
||||
}
|
||||
|
||||
// --- History Persistence ---
|
||||
|
||||
|
||||
property string stateFile: ""
|
||||
property bool isLoaded: false
|
||||
|
||||
@@ -164,7 +178,7 @@ Item {
|
||||
root.accessHistory = adapter.history;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onLoadFailed: error => {
|
||||
// If file doesn't exist (error 2), we are ready to save new data
|
||||
if (error === 2) {
|
||||
@@ -178,9 +192,9 @@ Item {
|
||||
|
||||
function saveHistory() {
|
||||
if (!stateFile || !isLoaded) return;
|
||||
|
||||
|
||||
adapter.history = root.accessHistory;
|
||||
|
||||
|
||||
// Ensure cache directory exists and save
|
||||
try {
|
||||
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir]);
|
||||
@@ -220,7 +234,7 @@ Item {
|
||||
|
||||
function checkAppChanges(newApps, oldApps, type, icon, colorKey) {
|
||||
if (!newApps && !oldApps) return;
|
||||
|
||||
|
||||
// Check for new apps (Started)
|
||||
if (newApps) {
|
||||
for (var i = 0; i < newApps.length; i++) {
|
||||
@@ -230,7 +244,7 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check for removed apps (Stopped)
|
||||
if (oldApps) {
|
||||
for (var j = 0; j < oldApps.length; j++) {
|
||||
@@ -279,6 +293,6 @@ Item {
|
||||
checkAppChanges(scrApps, _prevScrApps, "Screen", "screen-share", activeColorKey);
|
||||
_prevScrApps = scrApps;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user