import { bind } from 'astal'; import { Gtk, Widget } from 'astal/gtk3'; import AstalWp from 'gi://AstalWp'; import { RadioButton, ToggleButton } from '../misc/subclasses'; import Separator from '../misc/separator'; export default () => { const audio = AstalWp.get_default()?.get_audio(); if (!audio) { throw new Error('Could not find default audio devices.'); } // TODO: make a stack to have outputs, inputs and currently playing apps // TODO: figure out ports and profiles const defaultGroup = new RadioButton(); return ( {bind(audio, 'speakers').as((speakers) => speakers.map((speaker) => ( { speaker.connect('notify::isDefault', () => { self.active = speaker.isDefault; }); }} onToggled={(self) => { speaker.isDefault = self.active; }} /> { speaker.set_mute(self.active); (self.get_child() as Widget.Icon).icon = self.active ? 'audio-volume-muted-symbolic' : 'audio-speakers-symbolic'; }} > {/* FIXME: lockChannels not working TODO: have two sliders when lockChannels === false */} { speaker.set_lock_channels(self.active); (self.get_child() as Widget.Icon).icon = self.active ? 'channel-secure-symbolic' : 'channel-insecure-symbolic'; }} > { speaker.set_volume(self.value); }} /> )))} ); };