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>
This commit is contained in:
Rubin Bhandari
2024-11-08 15:16:21 +05:45
committed by GitHub
parent 9ae59034fa
commit 3cc3fa5d42
8 changed files with 68 additions and 20 deletions

31
lib/constants/distro.ts Normal file
View File

@@ -0,0 +1,31 @@
export const distroIcons = [
['deepin', ''],
['fedora', ''],
['arch', ''],
['nixos', ''],
['debian', ''],
['opensuse-tumbleweed', ''],
['ubuntu', ''],
['endeavouros', ''],
['manjaro', ''],
['popos', ''],
['garuda', ''],
['zorin', ''],
['mxlinux', ''],
['arcolinux', ''],
['gentoo', ''],
['artix', ''],
['centos', ''],
['hyperbola', ''],
['kubuntu', ''],
['mandriva', ''],
['xerolinux', ''],
['parabola', ''],
['void', ''],
['linuxmint', ''],
['archlabs', ''],
['devuan', ''],
['freebsd', ''],
['openbsd', ''],
['slackware', ''],
];

View File

@@ -11,6 +11,8 @@ import { NotificationArgs } from 'types/utils/notify';
import { SubstituteKeys } from './types/utils'; import { SubstituteKeys } from './types/utils';
import { Window } from 'types/@girs/gtk-3.0/gtk-3.0.cjs'; import { Window } from 'types/@girs/gtk-3.0/gtk-3.0.cjs';
import { namedColors } from './constants/colors'; import { namedColors } from './constants/colors';
import { distroIcons } from './constants/distro';
import { distro } from './variables';
export type Binding<T> = import('types/service').Binding<any, any, T>; export type Binding<T> = import('types/service').Binding<any, any, T>;
@@ -193,3 +195,8 @@ export const isValidGjsColor = (color: string): boolean => {
export const capitalizeFirstLetter = (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);
}; };
export function getDistroIcon(): string {
const icon = distroIcons.find(([id]) => id === distro.id);
return icon ? icon[1] : ''; // default icon if not found
}

View File

@@ -1,12 +1,13 @@
import Gdk from 'gi://Gdk?version=3.0';
import { openMenu } from '../utils.js';
import options from 'options';
import { BarBoxChild } from 'lib/types/bar.js';
import Button from 'types/widgets/button.js';
import { Attribute, Child } from 'lib/types/widget.js';
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js'; 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 } = options.bar.launcher; const { rightClick, middleClick, scrollUp, scrollDown, autoDetectIcon, icon } = options.bar.launcher;
const Menu = (): BarBoxChild => { const Menu = (): BarBoxChild => {
return { return {
@@ -22,7 +23,9 @@ const Menu = (): BarBoxChild => {
}), }),
child: Widget.Label({ child: Widget.Label({
class_name: 'bar-menu_label bar-button_icon txt-icon bar', class_name: 'bar-menu_label bar-button_icon txt-icon bar',
label: options.bar.launcher.icon.bind('value'), label: Utils.merge([autoDetectIcon.bind('value'), icon.bind('value')], (autoDetect, icon): string => {
return autoDetect ? getDistroIcon() : icon;
}),
}), }),
}), }),
isVisible: true, isVisible: true,

View File

@@ -1,12 +1,13 @@
const hyprland = await Service.import('hyprland'); const hyprland = await Service.import('hyprland');
import { BarBoxChild } from 'lib/types/bar';
import options from 'options';
import { Attribute, Child } from 'lib/types/widget';
import { ActiveClient } from 'types/service/hyprland';
import Label from 'types/widgets/label';
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils'; import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils';
import Button from 'types/widgets/button'; import { BarBoxChild } from 'lib/types/bar';
import { Attribute, Child } from 'lib/types/widget';
import { capitalizeFirstLetter } from 'lib/utils';
import options from 'options';
import Gdk from 'types/@girs/gdk-3.0/gdk-3.0'; import Gdk from 'types/@girs/gdk-3.0/gdk-3.0';
import { ActiveClient } from 'types/service/hyprland';
import Button from 'types/widgets/button';
import Label from 'types/widgets/label';
const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle; const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle;
@@ -117,7 +118,7 @@ const filterTitle = (windowtitle: ActiveClient): Record<string, string> => {
['^$', '󰇄', 'Desktop'], ['^$', '󰇄', 'Desktop'],
// Fallback icon // Fallback icon
['(.+)', '󰣆', `${windowtitle.class.charAt(0).toUpperCase() + windowtitle.class.slice(1)}`], ['(.+)', '󰣆', `${capitalizeFirstLetter(windowtitle.class)}}`],
]; ];
const foundMatch = windowTitleMap.find((wt) => RegExp(wt[0]).test(windowtitle.class.toLowerCase())); const foundMatch = windowTitleMap.find((wt) => RegExp(wt[0]).test(windowtitle.class.toLowerCase()));

View File

@@ -1,4 +1,5 @@
import { BoxWidget } from 'lib/types/widget'; import { BoxWidget } from 'lib/types/widget';
import { capitalizeFirstLetter } from 'lib/utils';
const network = await Service.import('network'); const network = await Service.import('network');
@@ -49,9 +50,7 @@ const Ethernet = (): BoxWidget => {
Widget.Label({ Widget.Label({
hpack: 'start', hpack: 'start',
class_name: 'connection-status dim', class_name: 'connection-status dim',
label: label: capitalizeFirstLetter(network.wired.internet),
network.wired.internet.charAt(0).toUpperCase() +
network.wired.internet.slice(1),
}), }),
], ],
}), }),

View File

@@ -1,7 +1,8 @@
import { PowerOptions } from 'lib/types/options'; import { PowerOptions } from 'lib/types/options';
import { GButton } from 'lib/types/widget';
import { capitalizeFirstLetter } from 'lib/utils';
import options from 'options'; import options from 'options';
import powermenu from '../power/helpers/actions'; import powermenu from '../power/helpers/actions';
import { GButton } from 'lib/types/widget';
const { confirmation, shutdown, logout, sleep, reboot, showLabel } = options.menus.power; const { confirmation, shutdown, logout, sleep, reboot, showLabel } = options.menus.power;
@@ -48,7 +49,7 @@ export const PowerButton = (action: PowerOptions): GButton => {
Widget.Label({ Widget.Label({
hpack: 'center', hpack: 'center',
hexpand: true, hexpand: true,
label: action.charAt(0).toUpperCase() + action.slice(1), label: capitalizeFirstLetter(action),
className: `power-button-label ${action}-label show-label`, className: `power-button-label ${action}-label show-label`,
}), }),
]; ];

View File

@@ -870,6 +870,7 @@ const options = mkOptions(OPTIONS, {
}), }),
launcher: { launcher: {
icon: opt('󰣇'), icon: opt('󰣇'),
autoDetectIcon: opt(false),
rightClick: opt(''), rightClick: opt(''),
middleClick: opt(''), middleClick: opt(''),
scrollUp: opt(''), scrollUp: opt(''),

View File

@@ -164,6 +164,11 @@ export const BarSettings = (): Scrollable<Gtk.Widget, Gtk.Widget> => {
title: 'Dashboard Menu Icon', title: 'Dashboard Menu Icon',
type: 'string', type: 'string',
}), }),
Option({
opt: options.bar.launcher.autoDetectIcon,
title: 'Auto Detect Icon',
type: 'boolean',
}),
Option({ Option({
opt: options.theme.bar.buttons.dashboard.enableBorder, opt: options.theme.bar.buttons.dashboard.enableBorder,
title: 'Button Border', title: 'Button Border',