1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 07:22:50 -05:00

Systematic cleanup and qmlfmt of all services

- qmlfmt kinda sucks but it's what qt creator uses
This commit is contained in:
bbedward
2025-09-02 22:45:06 -04:00
parent 21089aa66e
commit 531d6334fb
21 changed files with 1119 additions and 1223 deletions

View File

@@ -1,5 +1,6 @@
pragma Singleton
pragma ComponentBehavior: Bound
pragma ComponentBehavior
import QtQuick
import Quickshell
@@ -10,13 +11,15 @@ Singleton {
id: root
readonly property bool microphoneActive: {
if (!Pipewire.ready || !Pipewire.nodes?.values)
return false
if (!Pipewire.ready || !Pipewire.nodes?.values) {
return false
}
for (var i = 0; i < Pipewire.nodes.values.length; i++) {
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
const node = Pipewire.nodes.values[i]
if (!node)
continue
if (!node) {
continue
}
if ((node.type & PwNodeType.AudioInStream) === PwNodeType.AudioInStream) {
if (!looksLikeSystemVirtualMic(node)) {
@@ -32,22 +35,21 @@ Singleton {
}
PwObjectTracker {
objects: Pipewire.nodes.values.filter(
node => node.audio && !node.isStream
)
objects: Pipewire.nodes.values.filter(node => node.audio && !node.isStream)
}
readonly property bool cameraActive: {
if (!Pipewire.ready || !Pipewire.nodes?.values)
return false
if (!Pipewire.ready || !Pipewire.nodes?.values) {
return false
}
for (var i = 0; i < Pipewire.nodes.values.length; i++) {
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
const node = Pipewire.nodes.values[i]
if (!node || !node.ready)
continue
if (!node || !node.ready) {
continue
}
if (node.properties
&& node.properties["media.class"] === "Stream/Input/Video") {
if (node.properties && node.properties["media.class"] === "Stream/Input/Video") {
if (node.properties["stream.is-live"] === "true") {
return true
}
@@ -57,13 +59,15 @@ Singleton {
}
readonly property bool screensharingActive: {
if (!Pipewire.ready || !Pipewire.nodes?.values)
return false
if (!Pipewire.ready || !Pipewire.nodes?.values) {
return false
}
for (var i = 0; i < Pipewire.nodes.values.length; i++) {
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
const node = Pipewire.nodes.values[i]
if (!node || !node.ready)
continue
if (!node || !node.ready) {
continue
}
if ((node.type & PwNodeType.VideoSource) === PwNodeType.VideoSource) {
if (looksLikeScreencast(node)) {
@@ -71,15 +75,11 @@ Singleton {
}
}
if (node.properties
&& node.properties["media.class"] === "Stream/Input/Audio") {
const mediaName = (node.properties["media.name"]
|| "").toLowerCase()
const appName = (node.properties["application.name"]
|| "").toLowerCase()
if (node.properties && node.properties["media.class"] === "Stream/Input/Audio") {
const mediaName = (node.properties["media.name"] || "").toLowerCase()
const appName = (node.properties["application.name"] || "").toLowerCase()
if (mediaName.includes("desktop") || appName.includes("screen")
|| appName === "obs") {
if (mediaName.includes("desktop") || appName.includes("screen") || appName === "obs") {
if (node.properties["stream.is-live"] === "true") {
if (node.audio && node.audio.muted) {
return false
@@ -92,30 +92,27 @@ Singleton {
return false
}
readonly property bool anyPrivacyActive: microphoneActive || cameraActive
|| screensharingActive
readonly property bool anyPrivacyActive: microphoneActive || cameraActive || screensharingActive
function looksLikeSystemVirtualMic(node) {
if (!node)
if (!node) {
return false
}
const name = (node.name || "").toLowerCase()
const mediaName = (node.properties && node.properties["media.name"]
|| "").toLowerCase()
const appName = (node.properties && node.properties["application.name"]
|| "").toLowerCase()
const mediaName = (node.properties && node.properties["media.name"] || "").toLowerCase()
const appName = (node.properties && node.properties["application.name"] || "").toLowerCase()
const combined = name + " " + mediaName + " " + appName
return /cava|monitor|system/.test(combined)
}
function looksLikeScreencast(node) {
if (!node)
if (!node) {
return false
const appName = (node.properties && node.properties["application.name"]
|| "").toLowerCase()
}
const appName = (node.properties && node.properties["application.name"] || "").toLowerCase()
const nodeName = (node.name || "").toLowerCase()
const combined = appName + " " + nodeName
return /xdg-desktop-portal|xdpw|screencast|screen|gnome shell|kwin|obs/.test(
combined)
return /xdg-desktop-portal|xdpw|screencast|screen|gnome shell|kwin|obs/.test(combined)
}
function getMicrophoneStatus() {
@@ -132,14 +129,16 @@ Singleton {
function getPrivacySummary() {
const active = []
if (microphoneActive)
if (microphoneActive) {
active.push("microphone")
if (cameraActive)
}
if (cameraActive) {
active.push("camera")
if (screensharingActive)
}
if (screensharingActive) {
active.push("screensharing")
}
return active.length > 0 ? "Privacy active: " + active.join(
", ") : "No privacy concerns detected"
return active.length > 0 ? `Privacy active: ${active.join(", ")}` : "No privacy concerns detected"
}
}