diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-18 17:53:33 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-01-18 17:53:33 +1100 |
| commit | 89f4fe33042356d9a3e5ec96d06d64b29e533091 (patch) | |
| tree | 2ef77893f003fdc49183c0d7baef126236ad2dd6 /src/modules/bar.tsx | |
| parent | app: monitor scheme file (diff) | |
| download | caelestia-shell-89f4fe33042356d9a3e5ec96d06d64b29e533091.tar.gz caelestia-shell-89f4fe33042356d9a3e5ec96d06d64b29e533091.tar.bz2 caelestia-shell-89f4fe33042356d9a3e5ec96d06d64b29e533091.zip | |
bar: fix null pointer errors
Diffstat (limited to 'src/modules/bar.tsx')
| -rw-r--r-- | src/modules/bar.tsx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx index 05d7e9f..97787fc 100644 --- a/src/modules/bar.tsx +++ b/src/modules/bar.tsx @@ -125,7 +125,9 @@ const MediaPlaying = () => { }; const Workspace = ({ idx }: { idx: number }) => { - let wsId = Math.floor((hyprland.focusedWorkspace.id - 1) / config.wsPerGroup) * config.wsPerGroup + idx; + let wsId = hyprland.focusedWorkspace + ? Math.floor((hyprland.focusedWorkspace.id - 1) / config.wsPerGroup) * config.wsPerGroup + idx + : idx; return ( <button halign={Gtk.Align.CENTER} @@ -139,6 +141,7 @@ const Workspace = ({ idx }: { idx: number }) => { ); self.hook(hyprland, "notify::focused-workspace", () => { + if (!hyprland.focusedWorkspace) return; wsId = Math.floor((hyprland.focusedWorkspace.id - 1) / config.wsPerGroup) * config.wsPerGroup + idx; self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId); update(); @@ -147,7 +150,7 @@ const Workspace = ({ idx }: { idx: number }) => { self.hook(hyprland, "client-moved", update); self.hook(hyprland, "client-removed", update); - self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId); + self.toggleClassName("focused", hyprland.focusedWorkspace?.id === wsId); update(); }} /> @@ -159,7 +162,7 @@ const Workspaces = () => ( onScroll={(_, event) => { const activeWs = hyprland.focusedClient?.workspace.name; if (activeWs?.startsWith("special:")) hyprland.dispatch("togglespecialworkspace", activeWs.slice(8)); - else if (event.delta_y > 0 || hyprland.focusedWorkspace.id > 1) + else if (event.delta_y > 0 || hyprland.focusedWorkspace?.id > 1) hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1); }} > |