From 0518ec4214583bcc26f5b052f02fd93b12a00a77 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Fri, 17 Jan 2025 00:16:40 +1100
Subject: bluetoothdevices: make popup window
---
src/modules/popdowns/bluetoothdevices.tsx | 93 +++++++++++++++++++++++++++++++
src/modules/popdowns/index.tsx | 2 +
src/modules/popdowns/notifications.tsx | 2 +-
3 files changed, 96 insertions(+), 1 deletion(-)
create mode 100644 src/modules/popdowns/bluetoothdevices.tsx
(limited to 'src/modules/popdowns')
diff --git a/src/modules/popdowns/bluetoothdevices.tsx b/src/modules/popdowns/bluetoothdevices.tsx
new file mode 100644
index 0000000..f41516a
--- /dev/null
+++ b/src/modules/popdowns/bluetoothdevices.tsx
@@ -0,0 +1,93 @@
+import { bind, Variable } from "astal";
+import { Gtk } from "astal/gtk3";
+import AstalBluetooth from "gi://AstalBluetooth";
+import PopdownWindow from "../../widgets/popdownwindow";
+
+const BluetoothDevice = (device: AstalBluetooth.Device) => (
+
+ `${i}-symbolic`)} />
+
+);
+
+const List = () => (
+
+ {bind(AstalBluetooth.get_default(), "devices").as(d => d.map(BluetoothDevice))}
+
+);
+
+export default () => {
+ const bluetooth = AstalBluetooth.get_default();
+ const label = Variable("");
+
+ const update = () => {
+ const devices = bluetooth.get_devices();
+ const connected = devices.filter(d => d.connected).length;
+ label.set(`${connected} connected device${connected === 1 ? "" : "s"} (${devices.length} available)`);
+ };
+ bluetooth.get_devices().forEach(d => d.connect("notify::connected", update));
+ bluetooth.connect("device-added", (_, device) => device.connect("notify::connected", update));
+ bluetooth.connect("notify::devices", update);
+ update();
+
+ return (
+ n.length)}
+ countLabel={bind(label)}
+ headerButtons={[
+ {
+ label: bind(bluetooth, "isPowered").as(p => (p ? "Disable" : "Enable")),
+ onClicked: () => bluetooth.toggle(),
+ },
+ {
+ label: "Discovery",
+ onClicked: () => {
+ if (bluetooth.adapter.discovering) bluetooth.adapter.start_discovery();
+ else bluetooth.adapter.stop_discovery();
+ },
+ enabled: bind(bluetooth.adapter, "discovering"),
+ },
+ ]}
+ emptyIcon="bluetooth_disabled"
+ emptyLabel="No Bluetooth devices"
+ list={
}
+ />
+ );
+};
diff --git a/src/modules/popdowns/index.tsx b/src/modules/popdowns/index.tsx
index db3245b..ee6208d 100644
--- a/src/modules/popdowns/index.tsx
+++ b/src/modules/popdowns/index.tsx
@@ -1,9 +1,11 @@
+import BluetoothDevices from "./bluetoothdevices";
import Notifications from "./notifications";
import Updates from "./updates";
export default () => {
;
;
+ ;
return null;
};
diff --git a/src/modules/popdowns/notifications.tsx b/src/modules/popdowns/notifications.tsx
index bb08c13..4ab0095 100644
--- a/src/modules/popdowns/notifications.tsx
+++ b/src/modules/popdowns/notifications.tsx
@@ -51,7 +51,7 @@ export default () => (
{
label: "Silence",
onClicked: () => (AstalNotifd.get_default().dontDisturb = !AstalNotifd.get_default().dontDisturb),
- className: bind(AstalNotifd.get_default(), "dontDisturb").as(d => (d ? "enabled" : "")),
+ enabled: bind(AstalNotifd.get_default(), "dontDisturb"),
},
{
label: "Clear",
--
cgit v1.2.3-freya