Merge branch 'Jas-SinghFSU:master' into master
This commit is contained in:
20
customModules/submap/helpers.ts
Normal file
20
customModules/submap/helpers.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { Variable } from 'types/variable';
|
||||||
|
|
||||||
|
const hyprland = await Service.import('hyprland');
|
||||||
|
|
||||||
|
export const isSubmapEnabled = (submap: string, enabled: string, disabled: string): string => {
|
||||||
|
return submap !== 'default' ? enabled : disabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getInitialSubmap = (submapStatus: Variable<string>): void => {
|
||||||
|
let submap = hyprland.message('submap');
|
||||||
|
|
||||||
|
const newLineCarriage = /\n/g;
|
||||||
|
submap = submap.replace(newLineCarriage, '');
|
||||||
|
|
||||||
|
if (submap === 'unknown request') {
|
||||||
|
submap = 'default';
|
||||||
|
}
|
||||||
|
|
||||||
|
submapStatus.value = submap;
|
||||||
|
};
|
||||||
@@ -7,7 +7,8 @@ import Button from 'types/widgets/button';
|
|||||||
import { Variable as VariableType } from 'types/variable';
|
import { Variable as VariableType } from 'types/variable';
|
||||||
import { Attribute, Child } from 'lib/types/widget';
|
import { Attribute, Child } from 'lib/types/widget';
|
||||||
import { BarBoxChild } from 'lib/types/bar';
|
import { BarBoxChild } from 'lib/types/bar';
|
||||||
import { caapitalizeFirstLetter } from 'lib/utils';
|
import { capitalizeFirstLetter } from 'lib/utils';
|
||||||
|
import { getInitialSubmap, isSubmapEnabled } from './helpers';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
label,
|
label,
|
||||||
@@ -23,18 +24,24 @@ const {
|
|||||||
scrollDown,
|
scrollDown,
|
||||||
} = options.bar.customModules.submap;
|
} = options.bar.customModules.submap;
|
||||||
|
|
||||||
const submapStatus: VariableType<string> = Variable('');
|
const submapStatus: VariableType<string> = Variable('default');
|
||||||
|
|
||||||
hyprland.connect('submap', (_, currentSubmap) => {
|
hyprland.connect('submap', (_, currentSubmap) => {
|
||||||
|
if (currentSubmap.length === 0) {
|
||||||
|
submapStatus.value = 'default';
|
||||||
|
} else {
|
||||||
submapStatus.value = currentSubmap;
|
submapStatus.value = currentSubmap;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getInitialSubmap(submapStatus);
|
||||||
|
|
||||||
export const Submap = (): BarBoxChild => {
|
export const Submap = (): BarBoxChild => {
|
||||||
const submapModule = module({
|
const submapModule = module({
|
||||||
textIcon: Utils.merge(
|
textIcon: Utils.merge(
|
||||||
[submapStatus.bind('value'), enabledIcon.bind('value'), disabledIcon.bind('value')],
|
[submapStatus.bind('value'), enabledIcon.bind('value'), disabledIcon.bind('value')],
|
||||||
(status, enabled, disabled) => {
|
(status, enabled, disabled) => {
|
||||||
return status.length > 0 ? enabled : disabled;
|
return isSubmapEnabled(status, enabled, disabled);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
tooltipText: Utils.merge(
|
tooltipText: Utils.merge(
|
||||||
@@ -46,9 +53,9 @@ export const Submap = (): BarBoxChild => {
|
|||||||
],
|
],
|
||||||
(status, enabled, disabled, showSmName) => {
|
(status, enabled, disabled, showSmName) => {
|
||||||
if (showSmName) {
|
if (showSmName) {
|
||||||
return status.length > 0 ? caapitalizeFirstLetter(status) : 'Default';
|
return capitalizeFirstLetter(status);
|
||||||
}
|
}
|
||||||
return status.length > 0 ? enabled : disabled;
|
return isSubmapEnabled(status, enabled, disabled);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
boxClass: 'submap',
|
boxClass: 'submap',
|
||||||
@@ -61,9 +68,9 @@ export const Submap = (): BarBoxChild => {
|
|||||||
],
|
],
|
||||||
(status, enabled, disabled, showSmName) => {
|
(status, enabled, disabled, showSmName) => {
|
||||||
if (showSmName) {
|
if (showSmName) {
|
||||||
return status.length > 0 ? caapitalizeFirstLetter(status) : 'Default';
|
return capitalizeFirstLetter(status);
|
||||||
}
|
}
|
||||||
return status.length > 0 ? enabled : disabled;
|
return isSubmapEnabled(status, enabled, disabled);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
showLabelBinding: label.bind('value'),
|
showLabelBinding: label.bind('value'),
|
||||||
|
|||||||
@@ -190,6 +190,6 @@ export const isValidGjsColor = (color: string): boolean => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const caapitalizeFirstLetter = (str: string): string => {
|
export const capitalizeFirstLetter = (str: string): string => {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import Window from 'types/widgets/window.js';
|
|||||||
import { Attribute, Child } from 'lib/types/widget.js';
|
import { Attribute, Child } from 'lib/types/widget.js';
|
||||||
import options from 'options.js';
|
import options from 'options.js';
|
||||||
|
|
||||||
|
const { enabled: directoriesEnabled } = options.menus.dashboard.directories;
|
||||||
|
|
||||||
export default (): Window<Child, Attribute> => {
|
export default (): Window<Child, Attribute> => {
|
||||||
return DropdownMenu({
|
return DropdownMenu({
|
||||||
name: 'dashboardmenu',
|
name: 'dashboardmenu',
|
||||||
@@ -20,14 +22,22 @@ export default (): Window<Child, Attribute> => {
|
|||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: 'dashboard-content-container',
|
class_name: 'dashboard-content-container',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
children: [
|
children: directoriesEnabled.bind('value').as((isDirectoriesEnabled) => {
|
||||||
|
return [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
class_name: 'dashboard-content-items',
|
class_name: 'dashboard-content-items',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
children: [Profile(), Shortcuts(), Controls(), Directories(), Stats()],
|
children: [
|
||||||
}),
|
Profile(),
|
||||||
|
Shortcuts(),
|
||||||
|
Controls(),
|
||||||
|
...(isDirectoriesEnabled ? [Directories()] : []),
|
||||||
|
Stats(),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1103,6 +1103,7 @@ const options = mkOptions(OPTIONS, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
directories: {
|
directories: {
|
||||||
|
enabled: opt(true),
|
||||||
left: {
|
left: {
|
||||||
directory1: {
|
directory1: {
|
||||||
label: opt(' Downloads'),
|
label: opt(' Downloads'),
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ if (!dependencies('brightnessctl')) App.quit();
|
|||||||
|
|
||||||
const get = (args: string): number => Number(Utils.exec(`brightnessctl ${args}`));
|
const get = (args: string): number => Number(Utils.exec(`brightnessctl ${args}`));
|
||||||
const screen = await bash`ls -w1 /sys/class/backlight | head -1`;
|
const screen = await bash`ls -w1 /sys/class/backlight | head -1`;
|
||||||
const kbd = await bash`ls -w1 /sys/class/leds | head -1`;
|
const kbd = await bash`ls -w1 /sys/class/leds | grep '::kbd_backlight$' | head -1`;
|
||||||
|
|
||||||
class Brightness extends Service {
|
class Brightness extends Service {
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ export const DashboardMenuSettings = (): Scrollable<Child, Attribute> => {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
Header('Directories'),
|
Header('Directories'),
|
||||||
|
Option({ opt: options.menus.dashboard.directories.enabled, title: 'Enabled', type: 'boolean' }),
|
||||||
Option({
|
Option({
|
||||||
opt: options.menus.dashboard.directories.left.directory1.label,
|
opt: options.menus.dashboard.directories.left.directory1.label,
|
||||||
title: 'Left - Directory 1 (Label)',
|
title: 'Left - Directory 1 (Label)',
|
||||||
|
|||||||
Reference in New Issue
Block a user