From 72e349e368f6d4600512354e75551b380cbf70c7 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 27 Mar 2025 18:02:40 +1100 Subject: sidebar: audio device selector module --- scss/sidebar.scss | 110 +++++++++++++++++++++ src/modules/sidebar/audio.tsx | 3 + src/modules/sidebar/modules/deviceselector.tsx | 126 +++++++++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 src/modules/sidebar/modules/deviceselector.tsx diff --git a/scss/sidebar.scss b/scss/sidebar.scss index 369ad25..2a71995 100644 --- a/scss/sidebar.scss +++ b/scss/sidebar.scss @@ -507,6 +507,116 @@ } } + .device-selector { + @include lib.spacing(10, true); + + .selector { + @include lib.rounded(20); + + background-color: color.change(scheme.$surface1, $alpha: 0.4); + padding: lib.s(10) lib.s(15); + + .icon { + font-size: lib.s(20); + } + + .separator { + margin-bottom: lib.s(8); + margin-top: lib.s(5); + background-color: if(scheme.$light, scheme.$overlay1, scheme.$overlay0); + } + + .list { + color: scheme.$subtext0; + + @include lib.spacing(3, true); + } + + .device { + @include lib.spacing; + } + + .selected { + color: scheme.$text; + + @include lib.spacing(10); + + .icon { + font-size: lib.s(32); + } + + .sublabel { + color: scheme.$subtext0; + } + } + + button { + @include lib.element-decel; + + &:hover, + &:focus { + color: scheme.$subtext1; + } + + &:active { + color: scheme.$text; + } + } + } + + .stream { + @include lib.rounded(20); + @include lib.element-decel; + + background-color: color.change(scheme.$surface1, $alpha: 0.4); + padding: lib.s(10) lib.s(15); + + @include lib.spacing(5); + + &.playing { + background-color: color.change(color.mix(scheme.$surface1, scheme.$primary, 50%), $alpha: 0.4); + } + + .icon { + font-size: lib.s(28); + margin-right: lib.s(12); + } + + .sublabel { + font-size: lib.s(14); + color: scheme.$subtext0; + } + + trough { + @include lib.rounded(10); + + min-width: lib.s(100); + min-height: lib.s(10); + background-color: color.change(scheme.$error, $alpha: 0.3); + + fill { + @include lib.rounded(10); + + background-color: color.change(scheme.$overlay0, $alpha: 1); + } + + highlight { + @include lib.rounded(10); + + background-color: scheme.$subtext1; + } + } + + & > button { + @include media-button; + + font-size: lib.s(18); + min-width: lib.s(20); + min-height: lib.s(20); + } + } + } + .networks { .list { @include lib.spacing(10, true); diff --git a/src/modules/sidebar/audio.tsx b/src/modules/sidebar/audio.tsx index a5c1651..20a6551 100644 --- a/src/modules/sidebar/audio.tsx +++ b/src/modules/sidebar/audio.tsx @@ -1,3 +1,4 @@ +import DeviceSelector from "./modules/deviceselector"; import Media from "./modules/media"; import Streams from "./modules/streams"; @@ -6,5 +7,7 @@ export default () => ( + + ); diff --git a/src/modules/sidebar/modules/deviceselector.tsx b/src/modules/sidebar/modules/deviceselector.tsx new file mode 100644 index 0000000..03acc97 --- /dev/null +++ b/src/modules/sidebar/modules/deviceselector.tsx @@ -0,0 +1,126 @@ +import { bind, execAsync, Variable, type Binding } from "astal"; +import { Astal, Gtk } from "astal/gtk3"; +import AstalWp from "gi://AstalWp"; + +const Device = ({ + input, + defaultDevice, + showDropdown, + device, +}: { + input?: boolean; + defaultDevice: Binding; + showDropdown: Variable; + device: AstalWp.Endpoint; +}) => ( + +); + +const DefaultDevice = ({ input, device }: { input?: boolean; device: AstalWp.Endpoint }) => ( + + +); + +const Selector = ({ input, audio }: { input?: boolean; audio: AstalWp.Audio }) => { + const showDropdown = Variable(false); + const defaultDevice = bind(audio, input ? "defaultMicrophone" : "defaultSpeaker"); + + return ( + + + + {bind(audio, input ? "microphones" : "speakers").as(ds => + ds.map(d => ( + + )) + )} + + + + + + ); +}; + +const NoWp = () => ( + + + + +); + +export default () => { + const audio = AstalWp.get_default()?.get_audio(); + + if (!audio) return ; + + return ( + + + + + ); +}; -- cgit v1.2.3-freya