Cleanup bluetooth module

This commit is contained in:
2024-07-12 10:35:35 +07:00
parent 440625f9be
commit 713771affa
4 changed files with 9 additions and 7 deletions

View File

@@ -30,6 +30,7 @@ in {
# TODO: Find a way to add this for ags only # TODO: Find a way to add this for ags only
covercolors covercolors
brightnessctl brightnessctl
blueberry
]; ];
# systemd.user.services.ags = { # systemd.user.services.ags = {
# Unit = { # Unit = {

View File

@@ -168,11 +168,11 @@ export const Menu = ({ name, icon, title, content, ...props }) =>
...props, ...props,
}); });
/** @param {{type: string} & import("../types/widgets/button").ButtonProps} props */ /** @param {{type?: string, command?: string} & import("../types/widgets/button").ButtonProps} props */
export const SettingsButton = ({ type, ...props }) => export const SettingsButton = ({ type, command, ...props }) =>
Widget.Button({ Widget.Button({
onClicked: () => { onClicked: () => {
Utils.execAsync(`gnome-control-center ${type}`); Utils.execAsync(command ?? `gnome-control-center ${type}`);
App.closeWindow("quicksettings"); App.closeWindow("quicksettings");
}, },
hexpand: true, hexpand: true,

View File

@@ -59,7 +59,7 @@ export const Selection = (props) =>
children: bluetooth.bind("devices").as((x) => x.map(DeviceItem)), children: bluetooth.bind("devices").as((x) => x.map(DeviceItem)),
}), }),
Widget.Separator({ className: "accent" }), Widget.Separator({ className: "accent" }),
SettingsButton({ type: "bluetooth" }), SettingsButton({ command: "blueberry" }),
], ],
...props, ...props,
}); });
@@ -70,11 +70,12 @@ const DeviceItem = (device) =>
children: [ children: [
Widget.Icon(`${device.icon_name}-symbolic`), Widget.Icon(`${device.icon_name}-symbolic`),
Widget.Label(device.name), Widget.Label(device.name),
Widget.Box({ hexpand: true }),
Widget.Label({ Widget.Label({
label: `${device.battery_percentage}%`, label: `${device.battery_percentage}%`,
css: "padding-right: 24px;",
visible: device.bind("battery_percentage").as((x) => x > 0), visible: device.bind("battery_percentage").as((x) => x > 0),
}), }),
Widget.Box({ hexpand: true }),
Widget.Spinner({ Widget.Spinner({
active: device.bind("connecting"), active: device.bind("connecting"),
visible: device.bind("connecting"), visible: device.bind("connecting"),
@@ -82,8 +83,8 @@ const DeviceItem = (device) =>
Widget.Switch({ Widget.Switch({
active: device.bind("connected"), active: device.bind("connected"),
visible: device.bind("connecting").as((p) => !p), visible: device.bind("connecting").as((p) => !p),
// sensitive: false,
setup: (self) => setup: (self) =>
// TODO: If connecting to the device failed, reset back the switch to `active: false`.
self.connect("state_set", () => { self.connect("state_set", () => {
device.setConnection(self.active); device.setConnection(self.active);
return true; return true;

View File

@@ -88,7 +88,7 @@ mark {
} }
switch { switch {
background-color: #000; background-color: #1E1E2E;
border-radius: 100px; border-radius: 100px;
} }