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
---
scss/sidebar.scss | 63 +++++++++++++++
src/modules/sidebar/connectivity.tsx | 7 ++
src/modules/sidebar/index.tsx | 6 +-
src/modules/sidebar/modules/bluetooth.tsx | 124 ++++++++++++++++++++++++++++++
4 files changed, 198 insertions(+), 2 deletions(-)
create mode 100644 src/modules/sidebar/connectivity.tsx
create mode 100644 src/modules/sidebar/modules/bluetooth.tsx
diff --git a/scss/sidebar.scss b/scss/sidebar.scss
index 8f4d6d7..8611ed9 100644
--- a/scss/sidebar.scss
+++ b/scss/sidebar.scss
@@ -283,4 +283,67 @@
}
}
}
+
+
+ .bluetooth {
+ .list {
+ @include lib.spacing(10, true);
+ }
+
+ .device {
+ @include lib.rounded(20);
+
+ background-color: color.change(scheme.$surface1, $alpha: 0.4);
+ padding: lib.s(10) lib.s(15);
+
+ @include lib.spacing(5);
+
+ &.connected {
+ background-color: color.change(color.mix(scheme.$surface1, scheme.$primary, 50%), $alpha: 0.4);
+
+ & > button {
+ background-color: color.change(color.mix(scheme.$surface1, scheme.$primary, 50%), $alpha: 0.5);
+
+ &:hover,
+ &:focus {
+ background-color: color.change(color.mix(scheme.$surface1, scheme.$primary, 30%), $alpha: 0.5);
+ }
+
+ &:active {
+ background-color: color.change(color.mix(scheme.$surface1, scheme.$primary, 20%), $alpha: 0.5);
+ }
+ }
+ }
+
+ .icon {
+ font-size: lib.s(28);
+ margin-right: lib.s(12);
+ }
+
+ .sublabel {
+ font-size: lib.s(14);
+ color: scheme.$subtext0;
+ }
+
+ & > button {
+ @include lib.rounded(1000);
+ @include lib.element-decel;
+ @include font.icon;
+
+ font-size: lib.s(18);
+ min-width: lib.s(30);
+ min-height: lib.s(30);
+ background-color: color.change(scheme.$surface1, $alpha: 0.5);
+
+ &:hover,
+ &:focus {
+ background-color: color.change(scheme.$surface2, $alpha: 0.5);
+ }
+
+ &:active {
+ background-color: color.change(scheme.$overlay0, $alpha: 0.5);
+ }
+ }
+ }
+ }
}
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