Touch up network menu and finish bluetooth menu rework.

This commit is contained in:
Jas Singh
2024-06-30 04:02:38 -07:00
parent de72c05088
commit 9cf5b0f5ea
19 changed files with 907 additions and 491 deletions

View File

@@ -0,0 +1,74 @@
const label = (bluetooth) => {
const searchInProgress = Variable(false);
const startRotation = () => {
searchInProgress.value = true;
setTimeout(() => {
searchInProgress.value = false;
}, 10 * 1000);
};
return Widget.Box({
class_name: "menu-label-container",
hpack: "fill",
vpack: "start",
children: [
Widget.Label({
class_name: "menu-label",
vpack: "start",
hpack: "start",
label: "Bluetooth",
}),
Widget.Box({
class_name: "controls-container",
vpack: "start",
children: [
Widget.Switch({
class_name: "menu-switch bluetooth",
hexpand: true,
hpack: "end",
active: bluetooth.bind("enabled"),
on_activate: ({ active }) => {
searchInProgress.value = false;
Utils.execAsync([
"bash",
"-c",
`bluetoothctl power ${active ? "on" : "off"}`,
]).catch((err) =>
console.error(
`bluetoothctl power ${active ? "on" : "off"}`,
err,
),
);
},
}),
Widget.Separator({
class_name: "menu-separator bluetooth",
}),
Widget.Button({
vpack: "center",
class_name: "menu-icon-button search",
on_primary_click: () => {
startRotation();
Utils.execAsync([
"bash",
"-c",
"bluetoothctl --timeout 120 scan on",
]).catch((err) => {
searchInProgress.value = false;
console.error("bluetoothctl --timeout 120 scan on", err);
});
},
child: Widget.Icon({
class_name: searchInProgress
.bind("value")
.as((v) => (v ? "spinning" : "")),
icon: "view-refresh-symbolic",
}),
}),
],
}),
],
});
};
export { label };