Added the ability to track when submap is enabled or disabled. (#282)
* Added submap custom module. * Captilazation is muy importante. * Add border config
This commit is contained in:
@@ -410,6 +410,73 @@ export const CustomModuleSettings = (): Scrollable<GtkWidget, Attribute> =>
|
||||
type: 'string',
|
||||
}),
|
||||
|
||||
/*
|
||||
************************************
|
||||
* SUBMAP *
|
||||
************************************
|
||||
*/
|
||||
Header('Submap'),
|
||||
Option({
|
||||
opt: options.theme.bar.buttons.modules.submap.enableBorder,
|
||||
title: 'Button Border',
|
||||
type: 'boolean',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.enabledIcon,
|
||||
title: 'Enabled Icon',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.disabledIcon,
|
||||
title: 'Disabled Icon',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.enabledText,
|
||||
title: 'Enabled Text',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.disabledText,
|
||||
title: 'Disabled Text',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.label,
|
||||
title: 'Show Label',
|
||||
type: 'boolean',
|
||||
}),
|
||||
Option({
|
||||
opt: options.theme.bar.buttons.modules.submap.spacing,
|
||||
title: 'Spacing',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.leftClick,
|
||||
title: 'Left Click',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.rightClick,
|
||||
title: 'Right Click',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.middleClick,
|
||||
title: 'Middle Click',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.scrollUp,
|
||||
title: 'Scroll Up',
|
||||
type: 'string',
|
||||
}),
|
||||
Option({
|
||||
opt: options.bar.customModules.submap.scrollDown,
|
||||
title: 'Scroll Down',
|
||||
type: 'string',
|
||||
}),
|
||||
|
||||
/*
|
||||
************************************
|
||||
* WEATHER *
|
||||
|
||||
76
customModules/submap/index.ts
Normal file
76
customModules/submap/index.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
const hyprland = await Service.import('hyprland');
|
||||
import options from 'options';
|
||||
import { module } from '../module';
|
||||
|
||||
import { inputHandler } from 'customModules/utils';
|
||||
import Button from 'types/widgets/button';
|
||||
import { Variable as VariableType } from 'types/variable';
|
||||
import { Attribute, Child } from 'lib/types/widget';
|
||||
import { BarBoxChild } from 'lib/types/bar';
|
||||
|
||||
const {
|
||||
label,
|
||||
enabledIcon,
|
||||
disabledIcon,
|
||||
enabledText,
|
||||
disabledText,
|
||||
leftClick,
|
||||
rightClick,
|
||||
middleClick,
|
||||
scrollUp,
|
||||
scrollDown,
|
||||
} = options.bar.customModules.submap;
|
||||
|
||||
const submapStatus: VariableType<boolean> = Variable(false);
|
||||
|
||||
hyprland.connect('submap', () => {
|
||||
submapStatus.value = !submapStatus.value;
|
||||
});
|
||||
|
||||
export const Submap = (): BarBoxChild => {
|
||||
const submapModule = module({
|
||||
textIcon: Utils.merge(
|
||||
[submapStatus.bind('value'), enabledIcon.bind('value'), disabledIcon.bind('value')],
|
||||
(status, enabled, disabled) => {
|
||||
return status ? enabled : disabled;
|
||||
},
|
||||
),
|
||||
tooltipText: Utils.merge(
|
||||
[submapStatus.bind('value'), enabledText.bind('value'), disabledText.bind('value')],
|
||||
(status, enabled, disabled) => {
|
||||
return status ? enabled : disabled;
|
||||
},
|
||||
),
|
||||
boxClass: 'submap',
|
||||
label: Utils.merge(
|
||||
[submapStatus.bind('value'), enabledText.bind('value'), disabledText.bind('value')],
|
||||
(status, enabled, disabled) => {
|
||||
return status ? enabled : disabled;
|
||||
},
|
||||
),
|
||||
showLabelBinding: label.bind('value'),
|
||||
props: {
|
||||
setup: (self: Button<Child, Attribute>) => {
|
||||
inputHandler(self, {
|
||||
onPrimaryClick: {
|
||||
cmd: leftClick,
|
||||
},
|
||||
onSecondaryClick: {
|
||||
cmd: rightClick,
|
||||
},
|
||||
onMiddleClick: {
|
||||
cmd: middleClick,
|
||||
},
|
||||
onScrollUp: {
|
||||
cmd: scrollUp,
|
||||
},
|
||||
onScrollDown: {
|
||||
cmd: scrollDown,
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return submapModule;
|
||||
};
|
||||
@@ -116,6 +116,23 @@ export const CustomModuleTheme = (): Scrollable<GtkWidget, Attribute> => {
|
||||
}),
|
||||
Option({ opt: options.theme.bar.buttons.modules.updates.border, title: 'Border', type: 'color' }),
|
||||
|
||||
Header('Submap'),
|
||||
Option({ opt: options.theme.bar.buttons.modules.submap.text, title: 'Text', type: 'color' }),
|
||||
Option({ opt: options.theme.bar.buttons.modules.submap.icon, title: 'Icon', type: 'color' }),
|
||||
Option({
|
||||
opt: options.theme.bar.buttons.modules.submap.background,
|
||||
title: 'Label Background',
|
||||
type: 'color',
|
||||
}),
|
||||
Option({
|
||||
opt: options.theme.bar.buttons.modules.submap.icon_background,
|
||||
title: 'Icon Background',
|
||||
subtitle:
|
||||
"Applies a background color to the icon section of the button.\nRequires 'split' button styling.",
|
||||
type: 'color',
|
||||
}),
|
||||
Option({ opt: options.theme.bar.buttons.modules.submap.border, title: 'Border', type: 'color' }),
|
||||
|
||||
Header('Weather'),
|
||||
Option({ opt: options.theme.bar.buttons.modules.weather.icon, title: 'Icon', type: 'color' }),
|
||||
Option({ opt: options.theme.bar.buttons.modules.weather.text, title: 'Text', type: 'color' }),
|
||||
|
||||
Reference in New Issue
Block a user