Extract audio default device helpers

This commit is contained in:
David Heinemeier Hansson
2026-05-21 11:53:48 +02:00
parent e5b585d6b3
commit 8734464439
3 changed files with 50 additions and 12 deletions
+10 -12
View File
@@ -309,12 +309,11 @@ Panel {
if (!node) return
Pipewire.preferredDefaultAudioSink = node
if (root.bar && node.id !== undefined && node.name) {
var idArg = Util.shellQuote(String(node.id))
var nameArg = Util.shellQuote(String(node.name))
root.bar.run("wpctl set-default " + idArg + " 2>/dev/null || true; "
+ "pactl set-default-sink " + nameArg + " 2>/dev/null || true; "
+ "pactl list short sink-inputs 2>/dev/null | awk '{ print $1 }' | while read -r input; do "
+ "pactl move-sink-input \"$input\" " + nameArg + " 2>/dev/null || true; done")
Quickshell.execDetached([
root.bar.omarchyPath + "/bin/omarchy-audio-output-set-default",
String(node.id),
String(node.name)
])
}
}
@@ -322,12 +321,11 @@ Panel {
if (!node) return
Pipewire.preferredDefaultAudioSource = node
if (root.bar && node.id !== undefined && node.name) {
var idArg = Util.shellQuote(String(node.id))
var nameArg = Util.shellQuote(String(node.name))
root.bar.run("wpctl set-default " + idArg + " 2>/dev/null || true; "
+ "pactl set-default-source " + nameArg + " 2>/dev/null || true; "
+ "pactl list short source-outputs 2>/dev/null | awk '{ print $1 }' | while read -r output; do "
+ "pactl move-source-output \"$output\" " + nameArg + " 2>/dev/null || true; done")
Quickshell.execDetached([
root.bar.omarchyPath + "/bin/omarchy-audio-input-set-default",
String(node.id),
String(node.name)
])
}
}