Merge pull request #105 from anasgets111/main

stop showing negative workspaces (till proper way of dealing with them
This commit is contained in:
Lysec 2025-08-12 12:36:08 +02:00 committed by GitHub
commit 7edb670584
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,7 +33,7 @@ Singleton {
} catch (e) { } catch (e) {
console.log("Hyprland not available:", e); console.log("Hyprland not available:", e);
} }
if (typeof Niri !== "undefined") { if (typeof Niri !== "undefined") {
console.log("Detected Niri service"); console.log("Detected Niri service");
isHyprland = false; isHyprland = false;
@ -41,7 +41,7 @@ Singleton {
initNiri(); initNiri();
return; return;
} }
console.log("No supported compositor detected"); console.log("No supported compositor detected");
} catch (e) { } catch (e) {
console.error("Error detecting compositor:", e); console.error("Error detecting compositor:", e);
@ -83,18 +83,21 @@ Singleton {
function updateHyprlandWorkspaces() { function updateHyprlandWorkspaces() {
workspaces.clear(); workspaces.clear();
try { try {
for (let i = 0; i < hlWorkspaces.length; i++) { for (let i = 0; i < hlWorkspaces.length; i++) {
const ws = hlWorkspaces[i]; const ws = hlWorkspaces[i];
workspaces.append({ // Only append workspaces with id >= 1
id: i, if (ws.id >= 1) {
idx: ws.id, workspaces.append({
name: ws.name || "", id: i,
output: ws.monitor?.name || "", idx: ws.id,
isActive: ws.active === true, name: ws.name || "",
isFocused: ws.focused === true, output: ws.monitor?.name || "",
isUrgent: ws.urgent === true isActive: ws.active === true,
}); isFocused: ws.focused === true,
isUrgent: ws.urgent === true
});
}
} }
workspacesChanged(); workspacesChanged();
} catch (e) { } catch (e) {
@ -108,7 +111,7 @@ Singleton {
Connections { Connections {
target: Niri target: Niri
function onWorkspacesChanged() { function onWorkspacesChanged() {
updateNiriWorkspaces(); updateNiriWorkspaces();
} }
} }
@ -129,11 +132,11 @@ Singleton {
isOccupied: ws.isOccupied === true, isOccupied: ws.isOccupied === true,
}); });
} }
workspacesChanged(); workspacesChanged();
} }
function switchToWorkspace(workspaceId) { function switchToWorkspace(workspaceId) {
if (isHyprland) { if (isHyprland) {
try { try {
Hyprland.dispatch(`workspace ${workspaceId}`); Hyprland.dispatch(`workspace ${workspaceId}`);
@ -150,4 +153,4 @@ Singleton {
console.warn("No supported compositor detected for workspace switching"); console.warn("No supported compositor detected for workspace switching");
} }
} }
} }