From 8021e580a24fa4703238af27da3bbdee7ff4b144 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Wed, 26 Mar 2025 16:54:08 +1100
Subject: sidebar: connectivity pane
Bluetooth module
---
src/modules/sidebar/connectivity.tsx | 7 ++
src/modules/sidebar/index.tsx | 6 +-
src/modules/sidebar/modules/bluetooth.tsx | 124 ++++++++++++++++++++++++++++++
3 files changed, 135 insertions(+), 2 deletions(-)
create mode 100644 src/modules/sidebar/connectivity.tsx
create mode 100644 src/modules/sidebar/modules/bluetooth.tsx
(limited to 'src/modules')
diff --git a/src/modules/sidebar/connectivity.tsx b/src/modules/sidebar/connectivity.tsx
new file mode 100644
index 0000000..437e513
--- /dev/null
+++ b/src/modules/sidebar/connectivity.tsx
@@ -0,0 +1,7 @@
+import Bluetooth from "./modules/bluetooth";
+
+export default () => (
+
+
+
+);
diff --git a/src/modules/sidebar/index.tsx b/src/modules/sidebar/index.tsx
index 49a118b..2a13f5c 100644
--- a/src/modules/sidebar/index.tsx
+++ b/src/modules/sidebar/index.tsx
@@ -2,12 +2,13 @@ import type { Monitor } from "@/services/monitors";
import { bind, register, Variable } from "astal";
import { App, Astal, Gdk, Gtk, Widget } from "astal/gtk3";
import { sidebar } from "config";
+import Connectivity from "./connectivity";
import Dashboard from "./dashboard";
import NotifPane from "./notifpane";
@register()
export default class SideBar extends Widget.Window {
- readonly shown: Variable = Variable("dashboard");
+ readonly shown: Variable;
constructor({ monitor }: { monitor: Monitor }) {
super({
@@ -20,7 +21,8 @@ export default class SideBar extends Widget.Window {
visible: sidebar.showOnStartup.get(),
});
- const panes = [, ];
+ const panes = [, , ];
+ this.shown = Variable(panes[0].name);
this.add(
{
+ if (a.connected || b.connected) return a.connected ? -1 : 1;
+ if (a.paired || b.paired) return a.paired ? -1 : 1;
+ return 0;
+};
+
+const BluetoothDevice = (device: AstalBluetooth.Device) => (
+ `device ${c ? "connected" : ""}`)}>
+
+ Astal.Icon.lookup_icon(`${i}-symbolic`) ? `${i}-symbolic` : "bluetooth-symbolic"
+ )}
+ />
+
+
+
+
+);
+
+const List = ({ devNotify }: { devNotify: Variable }) => (
+
+ {bind(devNotify).as(() => AstalBluetooth.get_default().devices.sort(sortDevices).map(BluetoothDevice))}
+
+);
+
+const NoDevices = () => (
+
+
+
+
+
+
+);
+
+export default () => {
+ const bluetooth = AstalBluetooth.get_default();
+ const devNotify = Variable(false); // Aggregator for device state changes (connected/paired)
+
+ const update = () => devNotify.set(!devNotify.get());
+ const connectSignals = (device: AstalBluetooth.Device) => {
+ device.connect("notify::connected", update);
+ device.connect("notify::paired", update);
+ };
+ bluetooth.get_devices().forEach(connectSignals);
+ bluetooth.connect("device-added", (_, device) => connectSignals(device));
+ bluetooth.connect("notify::devices", update);
+
+ return (
+
+
+
+ (d.length > 0 ? "list" : "empty"))}
+ >
+
+
+
+
+
+
+ );
+};
--
cgit v1.2.3-freya