Skip to content

Commit

Permalink
fix: active workspace sync error
Browse files Browse the repository at this point in the history
Related #449
Use hyprland socket2 event to update active workspace now. on my PC it
doesn't cause Resource temporarily unavailable issue now.
  • Loading branch information
wenjinnn committed Jun 17, 2024
1 parent 1115022 commit 5a05674
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/service/hyprland.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ export class Hyprland extends Service {
this._monitors.set(m.id, m);
if (m.focused) {
this._active.monitor.update(m.id, m.name);
this._active.workspace.update(m.activeWorkspace.id, m.activeWorkspace.name);
this._active.monitor.emit('changed');
this._active.workspace.emit('changed');
}
}
if (notify)
Expand All @@ -235,6 +233,17 @@ export class Hyprland extends Service {
}
}

private _updateActiveWorksapce(id: number, name: string, notify = true) {
try {
this._active.workspace.update(id, name);
this._active.workspace.emit('changed');
if (notify)
this.notify('workspaces');
} catch (error) {
logError(error);
}
}

private async _syncWorkspaces(notify = true) {
try {
const msg = await this.messageAsync('j/workspaces');
Expand Down Expand Up @@ -272,7 +281,9 @@ export class Hyprland extends Service {

try {
switch (e) {
case 'workspace':
case 'workspacev2':
this._updateActiveWorksapce(Number(argv[0]), argv[1]);
break;
case 'focusedmon':
await this._syncMonitors();
break;
Expand Down

0 comments on commit 5a05674

Please sign in to comment.