Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to track when submap is enabled or disabled. #282

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions customModules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
76 changes: 76 additions & 0 deletions customModules/submap/index.ts
Original file line number Diff line number Diff line change
@@ -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;
};
17 changes: 17 additions & 0 deletions customModules/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand Down
3 changes: 3 additions & 0 deletions modules/bar/Bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Netstat,
KbInput,
Updates,
Submap,
Weather,
Power,
} from './Exports';
Expand Down Expand Up @@ -57,6 +58,7 @@ type Section =
| 'netstat'
| 'kbinput'
| 'updates'
| 'submap'
| 'weather'
| 'power'
| 'systray';
Expand Down Expand Up @@ -108,6 +110,7 @@ const widget = {
netstat: (): Button<Child, Attribute> => WidgetContainer(Netstat()),
kbinput: (): Button<Child, Attribute> => WidgetContainer(KbInput()),
updates: (): Button<Child, Attribute> => WidgetContainer(Updates()),
submap: (): Button<Child, Attribute> => WidgetContainer(Submap()),
weather: (): Button<Child, Attribute> => WidgetContainer(Weather()),
power: (): Button<Child, Attribute> => WidgetContainer(Power()),
};
Expand Down
2 changes: 2 additions & 0 deletions modules/bar/Exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Storage } from 'customModules/storage/index';
import { Netstat } from 'customModules/netstat/index';
import { KbInput } from 'customModules/kblayout/index';
import { Updates } from 'customModules/updates/index';
import { Submap } from 'customModules/submap/index';
import { Weather } from 'customModules/weather/index';
import { Power } from 'customModules/power/index';

Expand All @@ -40,6 +41,7 @@ export {
Netstat,
KbInput,
Updates,
Submap,
Weather,
Power,
};
21 changes: 21 additions & 0 deletions options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ const options = mkOptions(OPTIONS, {
icon_background: opt(colors.base2),
spacing: opt('0.45em'),
},
submap: {
enableBorder: opt(false),
border: opt(colors.teal),
background: opt(colors.base2),
text: opt(colors.teal),
icon: opt(colors.teal),
icon_background: opt(colors.base2),
spacing: opt('0.45em'),
},
},
},
menus: {
Expand Down Expand Up @@ -993,6 +1002,18 @@ const options = mkOptions(OPTIONS, {
scrollUp: opt(''),
scrollDown: opt(''),
},
submap: {
label: opt(true),
enabledIcon: opt('󰌐'),
disabledIcon: opt('󰌌'),
enabledText: opt('Submap On'),
disabledText: opt('Submap off'),
leftClick: opt(''),
rightClick: opt(''),
middleClick: opt(''),
scrollUp: opt(''),
scrollDown: opt(''),
},
weather: {
label: opt(true),
unit: opt<UnitType>('imperial'),
Expand Down
27 changes: 27 additions & 0 deletions scss/style/customModules/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,33 @@
1.2em //
);

/*
* #################################
* # Submap Module Styling #
* #################################
*/
@include styleModule(
//
// class name
'submap',
// label color
$bar-buttons-modules-submap-text,
// icon color
$bar-buttons-modules-submap-icon,
// icon background if split style is used
$bar-buttons-modules-submap-icon_background,
// label background
$bar-buttons-modules-submap-background,
// inner spacing
$bar-buttons-modules-submap-spacing,
// if border enabled
$bar-buttons-modules-submap-enableBorder,
// border color
$bar-buttons-modules-submap-border,
// custom font size
1.2em //
);

/*
* #################################
* # Weather Module Styling #
Expand Down
Loading