mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-10 15:52:58 -04:00
audio: fix cycle output, improve icon resolution for sink fixes #1808
This commit is contained in:
@@ -43,7 +43,7 @@ Singleton {
|
||||
}
|
||||
|
||||
signal micMuteChanged
|
||||
signal audioOutputCycled(string deviceName)
|
||||
signal audioOutputCycled(string deviceName, string deviceIcon)
|
||||
signal deviceAliasChanged(string nodeName, string newAlias)
|
||||
signal wireplumberReloadStarted
|
||||
signal wireplumberReloadCompleted(bool success)
|
||||
@@ -67,7 +67,8 @@ Singleton {
|
||||
}
|
||||
|
||||
function getAvailableSinks() {
|
||||
return Pipewire.nodes.values.filter(node => node.audio && node.isSink && !node.isStream);
|
||||
const hidden = SessionData.hiddenOutputDeviceNames ?? [];
|
||||
return Pipewire.nodes.values.filter(node => node.audio && node.isSink && !node.isStream && !hidden.includes(node.name));
|
||||
}
|
||||
|
||||
function cycleAudioOutput() {
|
||||
@@ -75,20 +76,13 @@ Singleton {
|
||||
if (sinks.length < 2)
|
||||
return null;
|
||||
|
||||
const currentSink = root.sink;
|
||||
let currentIndex = -1;
|
||||
for (let i = 0; i < sinks.length; i++) {
|
||||
if (sinks[i] === currentSink) {
|
||||
currentIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const currentName = root.sink?.name ?? "";
|
||||
const currentIndex = sinks.findIndex(s => s.name === currentName);
|
||||
const nextIndex = (currentIndex + 1) % sinks.length;
|
||||
const nextSink = sinks[nextIndex];
|
||||
Pipewire.preferredDefaultAudioSink = nextSink;
|
||||
const name = displayName(nextSink);
|
||||
audioOutputCycled(name);
|
||||
audioOutputCycled(name, sinkIcon(nextSink));
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -690,6 +684,46 @@ EOFCONFIG
|
||||
}
|
||||
}
|
||||
|
||||
function sinkIcon(node) {
|
||||
if (!node)
|
||||
return "speaker";
|
||||
|
||||
const props = node.properties || {};
|
||||
const formFactor = (props["device.form-factor"] || "").toLowerCase();
|
||||
|
||||
switch (formFactor) {
|
||||
case "headphone":
|
||||
case "headset":
|
||||
case "hands-free":
|
||||
case "handset":
|
||||
return "headset";
|
||||
case "tv":
|
||||
case "monitor":
|
||||
return "tv";
|
||||
case "speaker":
|
||||
case "computer":
|
||||
case "hifi":
|
||||
case "portable":
|
||||
case "car":
|
||||
return "speaker";
|
||||
}
|
||||
|
||||
const bus = (props["device.bus"] || "").toLowerCase();
|
||||
if (bus === "bluetooth")
|
||||
return "headset";
|
||||
|
||||
const name = (node.name || "").toLowerCase();
|
||||
if (name.includes("hdmi"))
|
||||
return "tv";
|
||||
if (name.includes("iec958") || name.includes("spdif"))
|
||||
return "speaker";
|
||||
|
||||
if (bus === "usb")
|
||||
return "headset";
|
||||
|
||||
return "speaker";
|
||||
}
|
||||
|
||||
function displayName(node) {
|
||||
if (!node) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user