Files
custum-hyprpanel/modules/bar/window_title/index.ts
Jas Singh 3dc5bbbe13 Adding configuration options to change spacing between icons and labels inside the buttons in the bar. (#30)
* Branch protection check.

* Move button spacing config into the Configuration section instead of Theming.

* Partially Resolves #26 - Added the ability to configure outer spacing on the bar.

* Renamed all class names for buttons so they can be styled with margins.

* Added configurable spacing to buttons.

* Fixed styling for network module when using wifi.

* Fixed ghost margins that occur when labels are disabled in the bar buttons.

* Change the default page of the settings dialog to configuration.
2024-07-28 15:16:31 -07:00

49 lines
1.6 KiB
TypeScript

const hyprland = await Service.import("hyprland");
import { ActiveClient } from 'types/service/hyprland'
const filterTitle = (windowtitle: ActiveClient) => {
const windowTitleMap = [
["kitty", "󰄛", "Kitty Terminal"],
["firefox", "󰈹", "Firefox"],
["microsoft-edge", "󰇩", "Edge"],
["discord", "", "Discord"],
["org.kde.dolphin", "", "Dolphin"],
["plex", "󰚺", "Plex"],
["steam", "", "Steam"],
["spotify", "󰓇", "Spotify"],
["obsidian", "󱓧", "Obsidian"],
["^$", "󰇄", "Desktop"],
["(.+)", "󰣆", `${windowtitle.class.charAt(0).toUpperCase() + windowtitle.class.slice(1)}`],
];
const foundMatch = windowTitleMap.find((wt) =>
RegExp(wt[0]).test(windowtitle.class.toLowerCase()),
);
return {
icon: foundMatch ? foundMatch[1] : windowTitleMap[windowTitleMap.length - 1][1],
label: foundMatch ? foundMatch[2] : windowTitleMap[windowTitleMap.length - 1][2]
}
};
const ClientTitle = () => {
return {
component: Widget.Box({
children: [
Widget.Label({
class_name: "bar-button-icon windowtitle",
label: hyprland.active.bind("client").as((v) => filterTitle(v).icon),
}),
Widget.Label({
class_name: "bar-button-label windowtitle",
label: hyprland.active.bind("client").as((v) => filterTitle(v).label),
})
]
}),
isVisible: true,
boxClass: "windowtitle",
};
};
export { ClientTitle };