💥 fix(bar/special-workspaces): correct usage of getSymbolicIcon() method
also improved the `getSymbolicIcon()` method's code
This commit is contained in:
+4
-3
@@ -83,8 +83,9 @@ export function getAppIcon(app: (string|AstalApps.Application)): (string|undefin
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getSymbolicIcon(app: (string|AstalApps.Application)): (string|undefined) {
|
export function getSymbolicIcon(app: (string|AstalApps.Application)): (string|undefined) {
|
||||||
if (Astal.Icon.lookup_icon(`${getAppIcon(app)}-symbolic`))
|
const icon = getAppIcon(app);
|
||||||
return `${getAppIcon(app)}-symbolic`
|
|
||||||
|
|
||||||
return undefined;
|
return (icon && Astal.Icon.lookup_icon(`${icon}-symbolic`)) ?
|
||||||
|
`${icon}-symbolic`
|
||||||
|
: undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { bind, Variable } from "astal";
|
import { bind, Variable } from "astal";
|
||||||
import { Gtk, Widget } from "astal/gtk3"
|
import { Gtk, Widget } from "astal/gtk3"
|
||||||
import AstalHyprland from "gi://AstalHyprland";
|
import AstalHyprland from "gi://AstalHyprland";
|
||||||
import { getSymbolicIcon } from "../../scripts/apps";
|
import { getAppIcon, getSymbolicIcon } from "../../scripts/apps";
|
||||||
|
|
||||||
export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
|
export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
|
||||||
className: "special-ws-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));
|
return name.charAt(0).toUpperCase().concat(name.substring(1, name.length));
|
||||||
}),
|
}),
|
||||||
child: new Widget.Box({
|
child: new Widget.Box({
|
||||||
child: new Widget.Icon({
|
child: bind(workspace, "lastClient").as(lastClient =>
|
||||||
className: "last-app-icon",
|
new Widget.Icon({
|
||||||
visible: Variable.derive([
|
className: "last-app-icon",
|
||||||
bind(workspace, "lastClient"),
|
visible: Variable.derive([
|
||||||
bind(AstalHyprland.get_default(), "focusedWorkspace")
|
bind(workspace, "lastClient"),
|
||||||
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
|
bind(AstalHyprland.get_default(), "focusedWorkspace")
|
||||||
false : Boolean(lastClient))(),
|
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
|
||||||
icon: bind(workspace, "lastClient").as((lastClient) =>
|
false : Boolean(lastClient))(),
|
||||||
getSymbolicIcon(lastClient) ?? "image-missing")
|
icon: bind(lastClient, "initialClass").as((initialClass) =>
|
||||||
} as Widget.IconProps)
|
getSymbolicIcon(initialClass) ?? getAppIcon(initialClass) ??
|
||||||
|
"application-x-executable-symbolic")
|
||||||
|
} as Widget.IconProps)
|
||||||
|
)
|
||||||
} as Widget.BoxProps),
|
} as Widget.BoxProps),
|
||||||
onClickRelease: () => AstalHyprland.get_default().dispatch(
|
onClickRelease: () => AstalHyprland.get_default().dispatch(
|
||||||
"togglespecialworkspace", workspace.name.replace(/^special\:/, "")
|
"togglespecialworkspace", workspace.name.replace(/^special\:/, "")
|
||||||
|
|||||||
Reference in New Issue
Block a user