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..5dee601 --- /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];