diff --git a/flake.nix b/flake.nix index a079623..557eb41 100644 --- a/flake.nix +++ b/flake.nix @@ -73,7 +73,13 @@ # Define .overlay to expose the package as pkgs.hyprpanel based on the system overlay = final: prev: { - hyprpanel = self.packages.${prev.stdenv.system}.default; + hyprpanel = prev.writeShellScriptBin "hyprpanel" '' + if [ "$#" -eq 0 ]; then + exec ${self.packages.${final.stdenv.system}.default}/bin/hyprpanel + else + exec ${astal.packages.${final.stdenv.system}.io}/bin/astal -i hyprpanel "$@" + fi + ''; }; homeManagerModules.hyprpanel = import ./nix/module.nix self; diff --git a/src/components/bar/modules/window_title/helpers/title.ts b/src/components/bar/modules/window_title/helpers/title.ts index 333b18a..4fdb6ae 100644 --- a/src/components/bar/modules/window_title/helpers/title.ts +++ b/src/components/bar/modules/window_title/helpers/title.ts @@ -8,11 +8,11 @@ import AstalHyprland from 'gi://AstalHyprland?version=0.1'; * This function searches for a matching window title in the predefined `windowTitleMap` based on the class of the provided window. * If a match is found, it returns an object containing the icon and label for the window. If no match is found, it returns a default icon and label. * - * @param windowtitle The window object containing the class information. + * @param client The window object containing the class information. * * @returns An object containing the icon and label for the window. */ -export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record => { +export const getWindowMatch = (client: AstalHyprland.Client): Record => { const windowTitleMap = [ // user provided values ...options.bar.windowtitle.title_map.get(), @@ -119,17 +119,17 @@ export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record RegExp(wt[0]).test(windowtitle?.class.toLowerCase())); + const foundMatch = windowTitleMap.find((wt) => RegExp(wt[0]).test(client?.class.toLowerCase())); if (!foundMatch || foundMatch.length !== 3) { return { @@ -157,13 +157,12 @@ export const getWindowMatch = (windowtitle: AstalHyprland.Client): Record { - if (client === null) return getWindowMatch(client).label; - - if (useCustomTitle) return getWindowMatch(client).label; - if (useClassName) return client.class; + if (client === null || useCustomTitle) return getWindowMatch(client).label; const title = client.title; - // If the title is empty or only filled with spaces, fallback to the class name + + if (!title || useClassName) return client.class; + if (title.length === 0 || title.match(/^ *$/)) { return client.class; } diff --git a/src/components/bar/modules/workspaces/workspaces.tsx b/src/components/bar/modules/workspaces/workspaces.tsx index 65122d4..fa3f924 100644 --- a/src/components/bar/modules/workspaces/workspaces.tsx +++ b/src/components/bar/modules/workspaces/workspaces.tsx @@ -152,7 +152,7 @@ export const WorkspaceModule = ({ monitor }: WorkspaceModuleProps): JSX.Element self.toggleClassName('active', activeWorkspace === wsId); self.toggleClassName( 'occupied', - (hyprlandService.get_workspace(wsId)?.get_clients().length || 0) > 0, + (hyprlandService.get_workspace(wsId)?.get_clients()?.length || 0) > 0, ); }} /> diff --git a/src/components/bar/settings/config.tsx b/src/components/bar/settings/config.tsx index c3a940a..e43fc37 100644 --- a/src/components/bar/settings/config.tsx +++ b/src/components/bar/settings/config.tsx @@ -140,7 +140,10 @@ export const CustomModuleSettings = (): JSX.Element => {