fix: dont hardcode file manager and make use of $TERM (#361)

* feat: make executables dynamic

* feat: make executables dynamic

* Update modules/menus/dashboard/stats/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update widget/settings/pages/config/general/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update options.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/menus/dashboard/stats/index.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* fix: var to term

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
Rubin Bhandari
2024-10-26 11:57:33 +05:45
committed by GitHub
parent 2d1e230405
commit 37ab13a829
2 changed files with 36 additions and 72 deletions

View File

@@ -23,6 +23,11 @@ interval.connect('changed', () => {
storageService.updateTimer(interval.value); storageService.updateTimer(interval.value);
}); });
const handleClick = (): void => {
App.closeWindow('dashboardmenu');
Utils.execAsync(`bash -c "${terminal} -e btop"`).catch((err) => `Failed to open btop: ${err}`);
};
const Stats = (): BoxWidget => { const Stats = (): BoxWidget => {
const divide = ([total, free]: number[]): number => free / total; const divide = ([total, free]: number[]): number => free / total;
@@ -82,28 +87,18 @@ const Stats = (): BoxWidget => {
return (self.children = [ return (self.children = [
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return (): void => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.Label({ child: Widget.Label({
class_name: 'txt-icon', class_name: 'txt-icon',
label: '󰢮', label: '󰢮',
}), }),
}), }),
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return (): void => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.LevelBar({ child: Widget.LevelBar({
class_name: 'stats-bar', class_name: 'stats-bar',
hexpand: true, hexpand: true,
@@ -150,28 +145,18 @@ const Stats = (): BoxWidget => {
vpack: 'center', vpack: 'center',
children: [ children: [
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.Label({ child: Widget.Label({
class_name: 'txt-icon', class_name: 'txt-icon',
label: '', label: '',
}), }),
}), }),
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.LevelBar({ child: Widget.LevelBar({
class_name: 'stats-bar', class_name: 'stats-bar',
hexpand: true, hexpand: true,
@@ -199,28 +184,18 @@ const Stats = (): BoxWidget => {
hexpand: true, hexpand: true,
children: [ children: [
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.Label({ child: Widget.Label({
class_name: 'txt-icon', class_name: 'txt-icon',
label: '', label: '',
}), }),
}), }),
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.LevelBar({ child: Widget.LevelBar({
class_name: 'stats-bar', class_name: 'stats-bar',
hexpand: true, hexpand: true,
@@ -251,28 +226,18 @@ const Stats = (): BoxWidget => {
vpack: 'center', vpack: 'center',
children: [ children: [
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.Label({ child: Widget.Label({
class_name: 'txt-icon', class_name: 'txt-icon',
label: '󰋊', label: '󰋊',
}), }),
}), }),
Widget.Button({ Widget.Button({
on_primary_click: terminal.bind('value').as((term) => { on_primary_click: () => {
return () => { handleClick();
App.closeWindow('dashboardmenu'); },
Utils.execAsync(`bash -c "${term} -e btop"`).catch(
(err) => `Failed to open btop: ${err}`,
);
};
}),
child: Widget.LevelBar({ child: Widget.LevelBar({
class_name: 'stats-bar', class_name: 'stats-bar',
hexpand: true, hexpand: true,

View File

@@ -1114,29 +1114,29 @@ const options = mkOptions(OPTIONS, {
left: { left: {
directory1: { directory1: {
label: opt('󰉍 Downloads'), label: opt('󰉍 Downloads'),
command: opt('bash -c "dolphin $HOME/Downloads/"'), command: opt('bash -c "xdg-open $HOME/Downloads/"'),
}, },
directory2: { directory2: {
label: opt('󰉏 Videos'), label: opt('󰉏 Videos'),
command: opt('bash -c "dolphin $HOME/Videos/"'), command: opt('bash -c "xdg-open $HOME/Videos/"'),
}, },
directory3: { directory3: {
label: opt('󰚝 Projects'), label: opt('󰚝 Projects'),
command: opt('bash -c "dolphin $HOME/Projects/"'), command: opt('bash -c "xdg-open $HOME/Projects/"'),
}, },
}, },
right: { right: {
directory1: { directory1: {
label: opt('󱧶 Documents'), label: opt('󱧶 Documents'),
command: opt('bash -c "dolphin $HOME/Documents/"'), command: opt('bash -c "xdg-open $HOME/Documents/"'),
}, },
directory2: { directory2: {
label: opt('󰉏 Pictures'), label: opt('󰉏 Pictures'),
command: opt('bash -c "dolphin $HOME/Pictures/"'), command: opt('bash -c "xdg-open $HOME/Pictures/"'),
}, },
directory3: { directory3: {
label: opt('󱂵 Home'), label: opt('󱂵 Home'),
command: opt('bash -c "dolphin $HOME/"'), command: opt('bash -c "xdg-open $HOME/"'),
}, },
}, },
}, },
@@ -1160,8 +1160,7 @@ const options = mkOptions(OPTIONS, {
scalingPriority: opt<ScalingPriority>('gdk'), scalingPriority: opt<ScalingPriority>('gdk'),
terminal: opt('kitty'), terminal: opt('$TERM'),
tear: opt(false), tear: opt(false),
wallpaper: { wallpaper: {