💥 fix(bar/focused-client): str may not be null
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { Gtk } from "ags/gtk4";
|
import { Gtk } from "ags/gtk4";
|
||||||
import AstalHyprland from "gi://AstalHyprland";
|
|
||||||
import { createBinding, With } from "ags";
|
import { createBinding, With } from "ags";
|
||||||
import { variableToBoolean } from "../../scripts/utils";
|
import { variableToBoolean } from "../../scripts/utils";
|
||||||
import { getAppIcon, getSymbolicIcon } from "../../scripts/apps";
|
import { getAppIcon, getSymbolicIcon } from "../../scripts/apps";
|
||||||
|
|
||||||
import Pango from "gi://Pango?version=1.0";
|
import Pango from "gi://Pango?version=1.0";
|
||||||
|
import AstalHyprland from "gi://AstalHyprland";
|
||||||
|
|
||||||
|
|
||||||
const hyprland = AstalHyprland.get_default();
|
const hyprland = AstalHyprland.get_default();
|
||||||
|
|
||||||
@@ -16,13 +18,13 @@ export const FocusedClient = () => {
|
|||||||
return <Gtk.Box class={"focused-client"}
|
return <Gtk.Box class={"focused-client"}
|
||||||
visible={variableToBoolean(createBinding(hyprland, "focusedClient"))}>
|
visible={variableToBoolean(createBinding(hyprland, "focusedClient"))}>
|
||||||
<With value={focusedClient}>
|
<With value={focusedClient}>
|
||||||
{(focusedClient) => focusedClient && <Gtk.Box>
|
{(focusedClient) => focusedClient?.class && <Gtk.Box>
|
||||||
<Gtk.Image iconName={
|
<Gtk.Image iconName={createBinding(focusedClient, "class").as((clss) =>
|
||||||
createBinding(focusedClient, "class").as((clss) =>
|
|
||||||
getSymbolicIcon(clss) ?? getAppIcon(clss) ??
|
getSymbolicIcon(clss) ?? getAppIcon(clss) ??
|
||||||
getAppIcon(focusedClient.initialClass) ??
|
getAppIcon(focusedClient.initialClass) ??
|
||||||
"application-x-executable-symbolic")
|
"application-x-executable-symbolic"
|
||||||
} vexpand={true} />
|
)} vexpand
|
||||||
|
/>
|
||||||
|
|
||||||
<Gtk.Box valign={Gtk.Align.CENTER} class={"text-content"}
|
<Gtk.Box valign={Gtk.Align.CENTER} class={"text-content"}
|
||||||
orientation={Gtk.Orientation.VERTICAL}>
|
orientation={Gtk.Orientation.VERTICAL}>
|
||||||
@@ -30,11 +32,14 @@ export const FocusedClient = () => {
|
|||||||
<Gtk.Label class={"class"} xalign={0} maxWidthChars={55}
|
<Gtk.Label class={"class"} xalign={0} maxWidthChars={55}
|
||||||
ellipsize={Pango.EllipsizeMode.END}
|
ellipsize={Pango.EllipsizeMode.END}
|
||||||
label={createBinding(focusedClient, "class")}
|
label={createBinding(focusedClient, "class")}
|
||||||
tooltipText={createBinding(focusedClient, "class")}/>
|
tooltipText={createBinding(focusedClient, "class")}
|
||||||
|
/>
|
||||||
|
|
||||||
<Gtk.Label class={"title"} xalign={0} maxWidthChars={50}
|
<Gtk.Label class={"title"} xalign={0} maxWidthChars={50}
|
||||||
ellipsize={Pango.EllipsizeMode.END}
|
ellipsize={Pango.EllipsizeMode.END}
|
||||||
label={createBinding(focusedClient, "title")}
|
label={createBinding(focusedClient, "title")}
|
||||||
tooltipText={createBinding(focusedClient, "title")}/>
|
tooltipText={createBinding(focusedClient, "title")}
|
||||||
|
/>
|
||||||
</Gtk.Box>
|
</Gtk.Box>
|
||||||
</Gtk.Box>}
|
</Gtk.Box>}
|
||||||
</With>
|
</With>
|
||||||
|
|||||||
Reference in New Issue
Block a user