From e2486ddd308cd64c04ab5e18bc80be7002832b02 Mon Sep 17 00:00:00 2001 From: Michael Lohr Date: Thu, 28 Nov 2024 13:02:51 +0100 Subject: [PATCH 1/2] feat: Support pause feature (event & response) --- src/client.ts | 10 ++++++++++ src/types/events/index.ts | 1 + src/types/events/pause-changed-event.ts | 6 ++++++ src/types/responses/paused-response.ts | 3 +++ src/types/wm-events.ts | 6 +++++- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/types/events/pause-changed-event.ts create mode 100644 src/types/responses/paused-response.ts diff --git a/src/client.ts b/src/client.ts index ffb6441..0e44973 100644 --- a/src/client.ts +++ b/src/client.ts @@ -23,6 +23,7 @@ import { type RunCommandResponse, type SubscribeResponse, } from './types'; +import { PausedResponse } from './types/responses/paused-response'; export interface WmClientOptions { /** @@ -152,6 +153,15 @@ export class WmClient { ); } + /** + * Gets the current paused state. + * + * @throws If connection to IPC server fails. + */ + async queryPaused(): Promise { + return this._sendAndWaitReply('query paused'); + } + /** * Invokes a WM command (e.g. `"focus --workspace 1"`). * diff --git a/src/types/events/index.ts b/src/types/events/index.ts index 5136499..708bd25 100644 --- a/src/types/events/index.ts +++ b/src/types/events/index.ts @@ -12,3 +12,4 @@ export * from './window-unmanaged-event'; export * from './workspace-activated-event'; export * from './workspace-deactivated-event'; export * from './workspace-updated-event'; +export * from './pause-changed-event'; diff --git a/src/types/events/pause-changed-event.ts b/src/types/events/pause-changed-event.ts new file mode 100644 index 0000000..0d6a3ab --- /dev/null +++ b/src/types/events/pause-changed-event.ts @@ -0,0 +1,6 @@ +import { WmEventType } from '../wm-events'; + +export interface PauseChangedEvent { + eventType: WmEventType.PAUSE_CHANGED; + paused: boolean; +} diff --git a/src/types/responses/paused-response.ts b/src/types/responses/paused-response.ts new file mode 100644 index 0000000..bf883a0 --- /dev/null +++ b/src/types/responses/paused-response.ts @@ -0,0 +1,3 @@ +export interface PausedResponse { + paused: boolean; +} diff --git a/src/types/wm-events.ts b/src/types/wm-events.ts index 72c49a6..269a439 100644 --- a/src/types/wm-events.ts +++ b/src/types/wm-events.ts @@ -6,6 +6,7 @@ import type { MonitorAddedEvent, MonitorRemovedEvent, MonitorUpdatedEvent, + PauseChangedEvent, TilingDirectionChangedEvent, UserConfigChangedEvent, WindowManagedEvent, @@ -34,6 +35,7 @@ export enum WmEventType { WORKSPACE_ACTIVATED = 'workspace_activated', WORKSPACE_DEACTIVATED = 'workspace_deactivated', WORKSPACE_UPDATED = 'workspace_updated', + PAUSE_CHANGED = 'pause_changed', } /** @@ -53,7 +55,8 @@ export type WmEvent = | WindowUnmanagedEvent | WorkspaceActivatedEvent | WorkspaceDeactivatedEvent - | WorkspaceUpdatedEvent; + | WorkspaceUpdatedEvent + | PauseChangedEvent; /** * Utility type for getting event interface for given {@link WmEventType}. @@ -79,4 +82,5 @@ export type WmEventData = { [WmEventType.WORKSPACE_ACTIVATED]: WorkspaceActivatedEvent; [WmEventType.WORKSPACE_DEACTIVATED]: WorkspaceDeactivatedEvent; [WmEventType.WORKSPACE_UPDATED]: WorkspaceUpdatedEvent; + [WmEventType.PAUSE_CHANGED]: PauseChangedEvent; }[T]; From e9e572985eb597849ae4720572211d08ff20e9be Mon Sep 17 00:00:00 2001 From: lars-berger Date: Sun, 1 Dec 2024 02:18:50 +0800 Subject: [PATCH 2/2] prettier --- src/types/responses/paused-response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/responses/paused-response.ts b/src/types/responses/paused-response.ts index bf883a0..5dee601 100644 --- a/src/types/responses/paused-response.ts +++ b/src/types/responses/paused-response.ts @@ -1,3 +1,3 @@ export interface PausedResponse { - paused: boolean; + paused: boolean; }