Implemented the ability to specify the terminal to launch btop with.

This commit is contained in:
Jas Singh
2024-07-24 22:44:35 -07:00
parent 4c603d844c
commit 7fddcf0299
2 changed files with 283 additions and 262 deletions

View File

@@ -1,3 +1,7 @@
import options from "options";
const { terminal } = options;
const Stats = () => {
const divide = ([total, free]) => free / total;
@@ -131,21 +135,25 @@ const Stats = () => {
vpack: "center",
children: [
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
label: "",
}),
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
child: Widget.LevelBar({
class_name: "stats-bar",
hexpand: true,
@@ -173,21 +181,25 @@ const Stats = () => {
hexpand: true,
children: [
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
label: "",
}),
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
child: Widget.LevelBar({
class_name: "stats-bar",
hexpand: true,
@@ -213,21 +225,25 @@ const Stats = () => {
vpack: "center",
children: [
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
label: "󰢮",
}),
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
child: Widget.LevelBar({
class_name: "stats-bar",
hexpand: true,
@@ -253,28 +269,32 @@ const Stats = () => {
vpack: "center",
children: [
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
label: "󰋊",
}),
Widget.Button({
on_primary_click: () => {
on_primary_click: terminal.bind("value").as(term => {
return () => {
App.closeWindow("dashboardmenu");
Utils.execAsync('bash -c "kitty -e btop"').catch(
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
},
}
}),
child: Widget.LevelBar({
class_name: "stats-bar",
hexpand: true,
vpack: "center",
value: storage.bind("value").as((v) => v.percentage),
}),
}),
})
],
}),
Widget.Label({

View File

@@ -12,6 +12,7 @@ export const BarGeneral = () => {
Option({ opt: options.theme.font.name, title: 'Font', type: 'font' }),
Option({ opt: options.theme.font.size, title: 'Font Size', type: 'string' }),
Option({ opt: options.theme.font.weight, title: 'Font Weight', subtitle: "100, 200, 300, etc.", type: 'number' }),
Option({ opt: options.terminal, title: 'Terminal', subtitle: "Tools such as 'btop' will open in this terminal", type: 'string' }),
]
})
}