Files
custum-hyprpanel/modules/bar/menu/index.ts
Rubin Bhandari 3cc3fa5d42 feat: launcher icon auto detect from os name (#413)
* feat: launcher icon auto detect from os name

* feat: add more

* fix: revamp distro icon

* feat: on hover only show actions if available on notifications (#396)

* feat: on hover only show actions if available on notifications

* feat: on hover only show actions if available on notifications

* fix: make the change configurable

* fix: remove unneeded op

* Added the ability to scale a popover. (#443)

* Added the ability to scale a popover.

* Removed redundant code

* Provide a cli command to clear notifications. (#444)

* Added a cpu temperature custom module. (#446)

* Added a CPU Temperature module.

* Update defauls and add wiki link.

* Move celsius to fahr conversion to method.

* fix: move distoicons , use capitalizeLetter func

* fix: lint

* Rename dissto.ts to distro.ts

* Update lib/utils.ts

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
2024-11-08 01:31:21 -08:00

60 lines
2.6 KiB
TypeScript

import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
import Gdk from 'gi://Gdk?version=3.0';
import { BarBoxChild } from 'lib/types/bar.js';
import { Attribute, Child } from 'lib/types/widget.js';
import options from 'options';
import Button from 'types/widgets/button.js';
import { openMenu } from '../utils.js';
import { getDistroIcon } from 'lib/utils.js';
const { rightClick, middleClick, scrollUp, scrollDown, autoDetectIcon, icon } = options.bar.launcher;
const Menu = (): BarBoxChild => {
return {
component: Widget.Box({
className: Utils.merge([options.theme.bar.buttons.style.bind('value')], (style) => {
const styleMap = {
default: 'style1',
split: 'style2',
wave: 'style3',
wave2: 'style3',
};
return `dashboard ${styleMap[style]}`;
}),
child: Widget.Label({
class_name: 'bar-menu_label bar-button_icon txt-icon bar',
label: Utils.merge([autoDetectIcon.bind('value'), icon.bind('value')], (autoDetect, icon): string => {
return autoDetect ? getDistroIcon() : icon;
}),
}),
}),
isVisible: true,
boxClass: 'dashboard',
props: {
on_primary_click: (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
openMenu(clicked, event, 'dashboardmenu');
},
setup: (self: Button<Child, Attribute>): void => {
self.hook(options.bar.scrollSpeed, () => {
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.value);
self.on_secondary_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
runAsyncCommand(rightClick.value, { clicked, event });
};
self.on_middle_click = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
runAsyncCommand(middleClick.value, { clicked, event });
};
self.on_scroll_up = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
throttledHandler(scrollUp.value, { clicked, event });
};
self.on_scroll_down = (clicked: Button<Child, Attribute>, event: Gdk.Event): void => {
throttledHandler(scrollDown.value, { clicked, event });
};
});
},
},
};
};
export { Menu };