💥 fix(bar/special-workspaces): correct usage of getSymbolicIcon() method

also improved the `getSymbolicIcon()` method's code
This commit is contained in:
retrozinndev
2025-06-18 18:51:30 -03:00
parent 2adbea8e57
commit ac65bba024
2 changed files with 18 additions and 14 deletions
+4 -3
View File
@@ -83,8 +83,9 @@ export function getAppIcon(app: (string|AstalApps.Application)): (string|undefin
}
export function getSymbolicIcon(app: (string|AstalApps.Application)): (string|undefined) {
if (Astal.Icon.lookup_icon(`${getAppIcon(app)}-symbolic`))
return `${getAppIcon(app)}-symbolic`
const icon = getAppIcon(app);
return undefined;
return (icon && Astal.Icon.lookup_icon(`${icon}-symbolic`)) ?
`${icon}-symbolic`
: undefined;
}
+7 -4
View File
@@ -1,7 +1,7 @@
import { bind, Variable } from "astal";
import { Gtk, Widget } from "astal/gtk3"
import AstalHyprland from "gi://AstalHyprland";
import { getSymbolicIcon } from "../../scripts/apps";
import { getAppIcon, getSymbolicIcon } from "../../scripts/apps";
export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
className: "special-ws-eventbox",
@@ -20,16 +20,19 @@ export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
return name.charAt(0).toUpperCase().concat(name.substring(1, name.length));
}),
child: new Widget.Box({
child: new Widget.Icon({
child: bind(workspace, "lastClient").as(lastClient =>
new Widget.Icon({
className: "last-app-icon",
visible: Variable.derive([
bind(workspace, "lastClient"),
bind(AstalHyprland.get_default(), "focusedWorkspace")
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
false : Boolean(lastClient))(),
icon: bind(workspace, "lastClient").as((lastClient) =>
getSymbolicIcon(lastClient) ?? "image-missing")
icon: bind(lastClient, "initialClass").as((initialClass) =>
getSymbolicIcon(initialClass) ?? getAppIcon(initialClass) ??
"application-x-executable-symbolic")
} as Widget.IconProps)
)
} as Widget.BoxProps),
onClickRelease: () => AstalHyprland.get_default().dispatch(
"togglespecialworkspace", workspace.name.replace(/^special\:/, "")