mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 01:02:18 -04:00
Screen sharing was not detected by PrivacyService on Niri because: 1. Niri creates the screencast as a Stream/Output/Video node, but screensharingActive only checked PwNodeType.VideoSource nodes. 2. looksLikeScreencast() only inspected application.name and node.name, missing Niri's node which has an empty application.name but identifies itself via media.name (niri-screen-cast-src). Add Stream/Output/Video to the checked media classes and include media.name in the screencast heuristic. Also add a forward-compatible check for NiriService.hasActiveCast for when Niri gains cast tracking in its IPC. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
156 lines
4.8 KiB
QML
156 lines
4.8 KiB
QML
pragma Singleton
|
|
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import Quickshell.Services.Pipewire
|
|
import qs.Services
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
readonly property bool microphoneActive: {
|
|
if (!Pipewire.ready || !Pipewire.nodes?.values) {
|
|
return false
|
|
}
|
|
|
|
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
|
|
const node = Pipewire.nodes.values[i]
|
|
if (!node) {
|
|
continue
|
|
}
|
|
|
|
if ((node.type & PwNodeType.AudioInStream) === PwNodeType.AudioInStream) {
|
|
if (!looksLikeSystemVirtualMic(node)) {
|
|
if (node.audio && node.audio.muted) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
PwObjectTracker {
|
|
objects: Pipewire.nodes.values.filter(node => !node.isStream)
|
|
}
|
|
|
|
readonly property bool cameraActive: {
|
|
if (!Pipewire.ready || !Pipewire.nodes?.values) {
|
|
return false
|
|
}
|
|
|
|
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
|
|
const node = Pipewire.nodes.values[i]
|
|
if (!node || !node.ready) {
|
|
continue
|
|
}
|
|
|
|
if (node.properties && node.properties["media.class"] === "Stream/Input/Video") {
|
|
if (node.properties["stream.is-live"] === "true") {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
readonly property bool screensharingActive: {
|
|
if (CompositorService.isNiri && NiriService.hasActiveCast) {
|
|
return true
|
|
}
|
|
|
|
if (!Pipewire.ready || !Pipewire.nodes?.values) {
|
|
return false
|
|
}
|
|
|
|
for (let i = 0; i < Pipewire.nodes.values.length; i++) {
|
|
const node = Pipewire.nodes.values[i]
|
|
if (!node || !node.ready) {
|
|
continue
|
|
}
|
|
|
|
if ((node.type & PwNodeType.VideoSource) === PwNodeType.VideoSource) {
|
|
if (looksLikeScreencast(node)) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
if (node.properties && node.properties["media.class"] === "Stream/Output/Video") {
|
|
if (looksLikeScreencast(node)) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
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 (node.properties["stream.is-live"] === "true") {
|
|
if (node.audio && node.audio.muted) {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
readonly property bool anyPrivacyActive: microphoneActive || cameraActive || screensharingActive
|
|
|
|
function looksLikeSystemVirtualMic(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 combined = name + " " + mediaName + " " + appName
|
|
return /cava|monitor|system/.test(combined)
|
|
}
|
|
|
|
function looksLikeScreencast(node) {
|
|
if (!node) {
|
|
return false
|
|
}
|
|
const appName = (node.properties && node.properties["application.name"] || "").toLowerCase()
|
|
const nodeName = (node.name || "").toLowerCase()
|
|
const mediaName = (node.properties && node.properties["media.name"] || "").toLowerCase()
|
|
const combined = appName + " " + nodeName + " " + mediaName
|
|
return /xdg-desktop-portal|xdpw|screencast|screen-cast|screen|gnome shell|kwin|obs|niri/.test(combined)
|
|
}
|
|
|
|
function getMicrophoneStatus() {
|
|
return microphoneActive ? "active" : "inactive"
|
|
}
|
|
|
|
function getCameraStatus() {
|
|
return cameraActive ? "active" : "inactive"
|
|
}
|
|
|
|
function getScreensharingStatus() {
|
|
return screensharingActive ? "active" : "inactive"
|
|
}
|
|
|
|
function getPrivacySummary() {
|
|
const active = []
|
|
if (microphoneActive) {
|
|
active.push("microphone")
|
|
}
|
|
if (cameraActive) {
|
|
active.push("camera")
|
|
}
|
|
if (screensharingActive) {
|
|
active.push("screensharing")
|
|
}
|
|
|
|
return active.length > 0 ? `Privacy active: ${active.join(", ")}` : "No privacy concerns detected"
|
|
}
|
|
}
|