mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
audio: fix cycle output, improve icon resolution for sink fixes #1808
This commit is contained in:
@@ -234,16 +234,7 @@ Rectangle {
|
|||||||
spacing: Theme.spacingS
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
name: {
|
name: AudioService.sinkIcon(modelData)
|
||||||
if (modelData.name.includes("bluez"))
|
|
||||||
return "headset";
|
|
||||||
else if (modelData.name.includes("hdmi"))
|
|
||||||
return "tv";
|
|
||||||
else if (modelData.name.includes("usb"))
|
|
||||||
return "headset";
|
|
||||||
else
|
|
||||||
return "speaker";
|
|
||||||
}
|
|
||||||
size: Theme.iconSize - 4
|
size: Theme.iconSize - 4
|
||||||
color: modelData === AudioService.sink ? Theme.primary : Theme.surfaceText
|
color: modelData === AudioService.sink ? Theme.primary : Theme.surfaceText
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|||||||
@@ -22,27 +22,14 @@ DankOSD {
|
|||||||
text: root.deviceName
|
text: root.deviceName
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIconForSink(sink) {
|
|
||||||
if (!sink)
|
|
||||||
return "speaker";
|
|
||||||
const name = sink.name || "";
|
|
||||||
if (name.includes("bluez"))
|
|
||||||
return "headset";
|
|
||||||
if (name.includes("hdmi"))
|
|
||||||
return "tv";
|
|
||||||
if (name.includes("usb"))
|
|
||||||
return "headset";
|
|
||||||
return "speaker";
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: AudioService
|
target: AudioService
|
||||||
|
|
||||||
function onAudioOutputCycled(name) {
|
function onAudioOutputCycled(name, icon) {
|
||||||
if (!SettingsData.osdAudioOutputEnabled)
|
if (!SettingsData.osdAudioOutputEnabled)
|
||||||
return;
|
return;
|
||||||
root.deviceName = name;
|
root.deviceName = name;
|
||||||
root.deviceIcon = getIconForSink(AudioService.sink);
|
root.deviceIcon = icon;
|
||||||
root.show();
|
root.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
signal micMuteChanged
|
signal micMuteChanged
|
||||||
signal audioOutputCycled(string deviceName)
|
signal audioOutputCycled(string deviceName, string deviceIcon)
|
||||||
signal deviceAliasChanged(string nodeName, string newAlias)
|
signal deviceAliasChanged(string nodeName, string newAlias)
|
||||||
signal wireplumberReloadStarted
|
signal wireplumberReloadStarted
|
||||||
signal wireplumberReloadCompleted(bool success)
|
signal wireplumberReloadCompleted(bool success)
|
||||||
@@ -67,7 +67,8 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAvailableSinks() {
|
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() {
|
function cycleAudioOutput() {
|
||||||
@@ -75,20 +76,13 @@ Singleton {
|
|||||||
if (sinks.length < 2)
|
if (sinks.length < 2)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const currentSink = root.sink;
|
const currentName = root.sink?.name ?? "";
|
||||||
let currentIndex = -1;
|
const currentIndex = sinks.findIndex(s => s.name === currentName);
|
||||||
for (let i = 0; i < sinks.length; i++) {
|
|
||||||
if (sinks[i] === currentSink) {
|
|
||||||
currentIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextIndex = (currentIndex + 1) % sinks.length;
|
const nextIndex = (currentIndex + 1) % sinks.length;
|
||||||
const nextSink = sinks[nextIndex];
|
const nextSink = sinks[nextIndex];
|
||||||
Pipewire.preferredDefaultAudioSink = nextSink;
|
Pipewire.preferredDefaultAudioSink = nextSink;
|
||||||
const name = displayName(nextSink);
|
const name = displayName(nextSink);
|
||||||
audioOutputCycled(name);
|
audioOutputCycled(name, sinkIcon(nextSink));
|
||||||
return name;
|
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) {
|
function displayName(node) {
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Reference in New Issue
Block a user