mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-22 00:39:58 -05:00
waffles: action center: volume menu
This commit is contained in:
+7
-14
@@ -10,15 +10,8 @@ import Quickshell.Services.Pipewire
|
||||
ColumnLayout {
|
||||
id: root
|
||||
required property bool isSink
|
||||
function correctType(node) {
|
||||
return (node.isSink === root.isSink) && node.audio
|
||||
}
|
||||
readonly property list<var> appPwNodes: Pipewire.nodes.values.filter((node) => { // Should be list<PwNode> but it breaks ScriptModel
|
||||
return root.correctType(node) && node.isStream
|
||||
})
|
||||
readonly property list<var> devices: Pipewire.nodes.values.filter(node => {
|
||||
return root.correctType(node) && !node.isStream
|
||||
})
|
||||
readonly property list<var> appPwNodes: isSink ? Audio.outputAppNodes : Audio.inputAppNodes
|
||||
readonly property list<var> devices: isSink ? Audio.outputDevices : Audio.inputDevices
|
||||
readonly property bool hasApps: appPwNodes.length > 0
|
||||
spacing: 16
|
||||
|
||||
@@ -44,21 +37,21 @@ ColumnLayout {
|
||||
Layout.fillHeight: false
|
||||
Layout.fillWidth: true
|
||||
Layout.bottomMargin: 6
|
||||
model: root.devices.map(node => (node.nickname || node.description || Translation.tr("Unknown")))
|
||||
model: root.devices.map(node => Audio.friendlyDeviceName(node))
|
||||
currentIndex: root.devices.findIndex(item => {
|
||||
if (root.isSink) {
|
||||
return item.id === Pipewire.preferredDefaultAudioSink?.id
|
||||
return item.id === Pipewire.defaultAudioSink?.id
|
||||
} else {
|
||||
return item.id === Pipewire.preferredDefaultAudioSource?.id
|
||||
return item.id === Pipewire.defaultAudioSource?.id
|
||||
}
|
||||
})
|
||||
onActivated: (index) => {
|
||||
print(index)
|
||||
const item = root.devices[index]
|
||||
if (root.isSink) {
|
||||
Pipewire.preferredDefaultAudioSink = item
|
||||
Audio.setDefaultSink(item)
|
||||
} else {
|
||||
Pipewire.preferredDefaultAudioSource = item
|
||||
Audio.setDefaultSource(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ Item {
|
||||
id: root
|
||||
required property PwNode node
|
||||
PwObjectTracker {
|
||||
objects: [node]
|
||||
objects: [root.node]
|
||||
}
|
||||
|
||||
implicitHeight: rowLayout.implicitHeight
|
||||
@@ -47,7 +47,7 @@ Item {
|
||||
elide: Text.ElideRight
|
||||
text: {
|
||||
// application.name -> description -> name
|
||||
const app = root.node?.properties["application.name"] ?? (root.node.description != "" ? root.node.description : root.node.name);
|
||||
const app = Audio.appNodeDisplayName(root.node);
|
||||
const media = root.node.properties["media.name"];
|
||||
return media != undefined ? `${app} • ${media}` : app;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user