From bdc42a765eaca94a9ad9626e3c3eec94d3587d27 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 7 Dec 2024 22:08:56 -0500 Subject: [PATCH] feat(ags audio): add profiles config --- .../ags/config/widgets/audio/main.tsx | 22 +++++----- .../ags/config/widgets/audio/profiles.tsx | 44 +++++++++++++++++++ .../ags/config/widgets/misc/subclasses.tsx | 11 +++++ 3 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 nixosModules/ags/config/widgets/audio/profiles.tsx diff --git a/nixosModules/ags/config/widgets/audio/main.tsx b/nixosModules/ags/config/widgets/audio/main.tsx index b4686b79..98ee0174 100644 --- a/nixosModules/ags/config/widgets/audio/main.tsx +++ b/nixosModules/ags/config/widgets/audio/main.tsx @@ -3,12 +3,10 @@ import { Gtk, Widget } from 'astal/gtk3'; import AstalWp from 'gi://AstalWp'; -import Separator from '../misc/separator'; import Streams from './streams'; +import Profiles from './profiles'; -const ICON_SEP = 6; - export default () => { const audio = AstalWp.get_default()?.get_audio(); @@ -16,9 +14,6 @@ export default () => { 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 Shown = Variable('outputs'); const stack = ( @@ -26,6 +21,7 @@ export default () => { shown={bind(Shown)} transitionType={Gtk.StackTransitionType.SLIDE_LEFT_RIGHT} > + {bind(audio, 'speakers').as(Streams)} @@ -37,6 +33,13 @@ export default () => { {bind(audio, 'microphones').as(Streams)} + + + + {bind(audio, 'devices').as(Profiles)} + + + ) as Widget.Stack; @@ -52,10 +55,6 @@ export default () => { > - - - - ) as Widget.Button; @@ -71,11 +70,10 @@ export default () => { > + {stack} - - ); }; diff --git a/nixosModules/ags/config/widgets/audio/profiles.tsx b/nixosModules/ags/config/widgets/audio/profiles.tsx new file mode 100644 index 00000000..e9e14654 --- /dev/null +++ b/nixosModules/ags/config/widgets/audio/profiles.tsx @@ -0,0 +1,44 @@ +import { bind } from 'astal'; + +import AstalWp from 'gi://AstalWp'; + +import { ComboBoxText } from '../misc/subclasses'; + + +export default (devices: AstalWp.Device[]) => devices.map((device) => ( + + + +)); diff --git a/nixosModules/ags/config/widgets/misc/subclasses.tsx b/nixosModules/ags/config/widgets/misc/subclasses.tsx index 59c5b596..fde7b9c7 100644 --- a/nixosModules/ags/config/widgets/misc/subclasses.tsx +++ b/nixosModules/ags/config/widgets/misc/subclasses.tsx @@ -49,3 +49,14 @@ export class ProgressBar extends astalify(Gtk.ProgressBar) { super(props as any); } } + +@register() +export class ComboBoxText extends astalify(Gtk.ComboBoxText) { + constructor(props: ConstructProps< + ComboBoxText, + Gtk.ComboBoxText.ConstructorProps + > = {}) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + super(props as any); + } +}