From 0e11b6f2cf1aab72ee0465078e3c914abb483c04 Mon Sep 17 00:00:00 2001 From: Mora Unie Youer Date: Sun, 2 Mar 2025 21:24:03 +0300 Subject: feat: add audio volume slider --- widget/bar/Bar.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'widget') diff --git a/widget/bar/Bar.tsx b/widget/bar/Bar.tsx index b057cdb..7492708 100644 --- a/widget/bar/Bar.tsx +++ b/widget/bar/Bar.tsx @@ -1,6 +1,7 @@ import { App, Astal, Gtk, Gdk } from "astal/gtk4" import { bind, exec, GLib, Variable } from "astal" import AstalTray from "gi://AstalTray?version=0.1"; +import AstalWp from "gi://AstalWp?version=0.1"; type NiriWorkspace = { id: number, @@ -59,6 +60,26 @@ function Workspaces(args: WorkspacesArguments) { } +function AudioVolume() { + const wireplumber = AstalWp.get_default()!; + const speaker = wireplumber.audio.get_default_speaker()!; + + return + + {/* {bind(speaker, "volume")} */} + speaker.volume += (dx + dy) * -0.05} + // BUG: this doesn't work due to value being updated immediately with dragging + // so that new value is never reached (slider "freezes") + // onChangeValue={({ value }) => new_volume = value} + // onKeyReleased={() => speaker.volume = new_volume} + value={bind(speaker, "volume")} + /> + ; +} + + function Tray() { // BUG: personally I have one fantom icon being along other tray icons // For now I don't have any ideas why this is happening @@ -114,6 +135,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) { + -- cgit v1.2.3-70-g09d2