Skip to content

Commit

Permalink
feat: make executables dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiin committed Oct 24, 2024
1 parent fcdba86 commit e8a24d1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 73 deletions.
95 changes: 30 additions & 65 deletions modules/menus/dashboard/stats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Cpu from 'services/Cpu';
import Storage from 'services/Storage';
import { renderResourceLabel } from 'customModules/utils';

const { terminal } = options;
const { enable_gpu, interval } = options.menus.dashboard.stats;

const ramService = new Ram();
Expand All @@ -23,6 +22,12 @@ interval.connect('changed', () => {
storageService.updateTimer(interval.value);
});


Check failure on line 25 in modules/menus/dashboard/stats/index.ts

View workflow job for this annotation

GitHub Actions / code_quality

Delete `⏎`
const handleClick = (): void => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "$TERMINAL -e btop"`).catch((err) => `Failed to open btop: ${err}`);
};

const Stats = (): BoxWidget => {
const divide = ([total, free]: number[]): number => free / total;

Expand Down Expand Up @@ -82,28 +87,18 @@ const Stats = (): BoxWidget => {

return (self.children = [
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return (): void => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.Label({
class_name: 'txt-icon',
label: '󰢮',
}),
}),
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return (): void => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.LevelBar({
class_name: 'stats-bar',
hexpand: true,
Expand Down Expand Up @@ -150,28 +145,18 @@ const Stats = (): BoxWidget => {
vpack: 'center',
children: [
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.Label({
class_name: 'txt-icon',
label: '',
}),
}),
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.LevelBar({
class_name: 'stats-bar',
hexpand: true,
Expand Down Expand Up @@ -199,28 +184,18 @@ const Stats = (): BoxWidget => {
hexpand: true,
children: [
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.Label({
class_name: 'txt-icon',
label: '',
}),
}),
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.LevelBar({
class_name: 'stats-bar',
hexpand: true,
Expand Down Expand Up @@ -251,28 +226,18 @@ const Stats = (): BoxWidget => {
vpack: 'center',
children: [
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.Label({
class_name: 'txt-icon',
label: '󰋊',
}),
}),
Widget.Button({
on_primary_click: terminal.bind('value').as((term) => {
return () => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
on_primary_click: () => {
handleClick();
},
child: Widget.LevelBar({
class_name: 'stats-bar',
hexpand: true,
Expand Down
14 changes: 6 additions & 8 deletions options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,29 +1114,29 @@ const options = mkOptions(OPTIONS, {
left: {
directory1: {
label: opt('󰉍 Downloads'),
command: opt('bash -c "dolphin $HOME/Downloads/"'),
command: opt('bash -c "xdg-open $HOME/Downloads/"'),
},
directory2: {
label: opt('󰉏 Videos'),
command: opt('bash -c "dolphin $HOME/Videos/"'),
command: opt('bash -c "xdg-open $HOME/Videos/"'),
},
directory3: {
label: opt('󰚝 Projects'),
command: opt('bash -c "dolphin $HOME/Projects/"'),
command: opt('bash -c "xdg-open $HOME/Projects/"'),
},
},
right: {
directory1: {
label: opt('󱧶 Documents'),
command: opt('bash -c "dolphin $HOME/Documents/"'),
command: opt('bash -c "xdg-open $HOME/Documents/"'),
},
directory2: {
label: opt('󰉏 Pictures'),
command: opt('bash -c "dolphin $HOME/Pictures/"'),
command: opt('bash -c "xdg-open $HOME/Pictures/"'),
},
directory3: {
label: opt('󱂵 Home'),
command: opt('bash -c "dolphin $HOME/"'),
command: opt('bash -c "xdg-open $HOME/"'),
},
},
},
Expand All @@ -1160,8 +1160,6 @@ const options = mkOptions(OPTIONS, {

scalingPriority: opt<ScalingPriority>('gdk'),

terminal: opt('kitty'),

tear: opt(false),

wallpaper: {
Expand Down

0 comments on commit e8a24d1

Please sign in to comment.