bar: fix null pointer errors
This commit is contained in:
parent
d9d12acb58
commit
89f4fe3304
1 changed files with 6 additions and 3 deletions
|
|
@ -125,7 +125,9 @@ const MediaPlaying = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Workspace = ({ idx }: { idx: number }) => {
|
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 (
|
return (
|
||||||
<button
|
<button
|
||||||
halign={Gtk.Align.CENTER}
|
halign={Gtk.Align.CENTER}
|
||||||
|
|
@ -139,6 +141,7 @@ const Workspace = ({ idx }: { idx: number }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.hook(hyprland, "notify::focused-workspace", () => {
|
self.hook(hyprland, "notify::focused-workspace", () => {
|
||||||
|
if (!hyprland.focusedWorkspace) return;
|
||||||
wsId = Math.floor((hyprland.focusedWorkspace.id - 1) / config.wsPerGroup) * config.wsPerGroup + idx;
|
wsId = Math.floor((hyprland.focusedWorkspace.id - 1) / config.wsPerGroup) * config.wsPerGroup + idx;
|
||||||
self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId);
|
self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId);
|
||||||
update();
|
update();
|
||||||
|
|
@ -147,7 +150,7 @@ const Workspace = ({ idx }: { idx: number }) => {
|
||||||
self.hook(hyprland, "client-moved", update);
|
self.hook(hyprland, "client-moved", update);
|
||||||
self.hook(hyprland, "client-removed", update);
|
self.hook(hyprland, "client-removed", update);
|
||||||
|
|
||||||
self.toggleClassName("focused", hyprland.focusedWorkspace.id === wsId);
|
self.toggleClassName("focused", hyprland.focusedWorkspace?.id === wsId);
|
||||||
update();
|
update();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -159,7 +162,7 @@ const Workspaces = () => (
|
||||||
onScroll={(_, event) => {
|
onScroll={(_, event) => {
|
||||||
const activeWs = hyprland.focusedClient?.workspace.name;
|
const activeWs = hyprland.focusedClient?.workspace.name;
|
||||||
if (activeWs?.startsWith("special:")) hyprland.dispatch("togglespecialworkspace", activeWs.slice(8));
|
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);
|
hyprland.dispatch("workspace", (event.delta_y < 0 ? "-" : "+") + 1);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue