[Astal] Fix audio issues

This commit is contained in:
Janis Hutz 2025-06-18 11:40:54 +02:00
parent 2e8f1ec9ae
commit 4189258def
3 changed files with 54 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { bind, Binding } from "astal";
import { bind } from "astal";
import { Gtk } from "astal/gtk4";
import AstalWp from "gi://AstalWp";
@ -107,7 +107,7 @@ const AudioModule = () => {
};
const SinkPicker = (type: AstalWp.MediaClass) => {
const devices = bind(wp, "endpoints");
const devices = bind(wp, "nodes");
return (
<box vertical>

View File

@ -0,0 +1,51 @@
{devices.as(d => {
return d.map(device => {
if (device.get_media_class() !== type) {
return <box cssClasses={[ 'empty' ]}></box>;
}
return (
<button
cssClasses={bind(device, "id").as(id => {
if (
id ===
(type ===
AstalWp.MediaClass.AUDIO_SPEAKER
? wp.defaultSpeaker.id
: type ===
AstalWp.MediaClass
.AUDIO_MICROPHONE
? wp.defaultMicrophone.id
: "")
) {
return [
"sink-option",
"currently-selected-sink-option",
];
} else {
return ["sink-option"];
}
})}
child={
<box halign={Gtk.Align.START}>
<image
iconName={bind(device, "icon").as(
icon => icon,
)}
marginEnd={3}
></image>
<label
label={bind(
device,
"description",
).as(t => t ?? "")}
></label>
</box>
}
onClicked={() => {
device.set_is_default(true);
}}
></button>
);
});
})}

2
setup
View File

@ -81,7 +81,7 @@ cp ./config/lint/.indentconfig.yaml ~
echo "
=> Installing yazi plugins
"
ya pack -i
ya pkg -i
echo "
=> Installing GTK Theme