@vicinae/api 0.16.6 → 0.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/bus.d.ts CHANGED
@@ -60,6 +60,7 @@ type EndpointMapping = {
60
60
  "wm.getScreens": "wm.getScreens";
61
61
  "wm.getWorkspaces": "wm.getWorkspaces";
62
62
  "wm.setWindowBounds": "wm.setWindowBounds";
63
+ "wm.focusWindow": "wm.focusWindow";
63
64
  "fileSearch.search": "fileSearch.search";
64
65
  "ui.popToRoot": "ui.popToRoot";
65
66
  "command.updateCommandMetadata": "command.updateCommandMetadata";
@@ -33,7 +33,7 @@ export declare namespace Clipboard {
33
33
  * or pasting content to it directly, this will fallback to a regular
34
34
  * clipboard copy.
35
35
  */
36
- function paste(text: string | Clipboard.Content): Promise<void>;
36
+ function paste(text: string | number | Clipboard.Content): Promise<void>;
37
37
  /**
38
38
  * Read the current content of the clipboard, which can contain text, html and a file path.
39
39
  * Note: the offset option is not yet implemented
@@ -12,7 +12,7 @@ var Clipboard;
12
12
  (function (Clipboard) {
13
13
  function mapContent(content) {
14
14
  let ct = clipboard_1.ClipboardContent.create();
15
- if (typeof content != "object") {
15
+ if (typeof content !== "object") {
16
16
  ct.text = `${content}`;
17
17
  }
18
18
  else {
package/dist/api/image.js CHANGED
@@ -66,7 +66,11 @@ const serializeProtoImage = (image) => {
66
66
  }
67
67
  const proto = ui.Image.create();
68
68
  const img = image;
69
- proto.source = serializeSource(img.source);
69
+ // img.source should technically not be null, but it somehow still happens at times with some
70
+ // raycast extensions
71
+ if (img.source) {
72
+ proto.source = serializeSource(img.source);
73
+ }
70
74
  if (img.fallback) {
71
75
  proto.fallback = serializeSource(img.fallback);
72
76
  }
@@ -3,6 +3,7 @@ import { Application } from "./application";
3
3
  export declare const protobufPackage = "proto.ext.wm";
4
4
  export interface Window {
5
5
  id: string;
6
+ title: string;
6
7
  workspaceId: string;
7
8
  active: boolean;
8
9
  fullscreen: boolean;
@@ -34,6 +35,12 @@ export interface PingRequest {
34
35
  export interface PingResponse {
35
36
  ok: boolean;
36
37
  }
38
+ export interface FocusWindowRequest {
39
+ id: string;
40
+ }
41
+ export interface FocusWindowResponse {
42
+ ok: boolean;
43
+ }
37
44
  export interface GetActiveWindowRequest {
38
45
  }
39
46
  export interface GetActiveWindowResponse {
@@ -79,6 +86,7 @@ export interface Request {
79
86
  getScreens?: GetScreensRequest | undefined;
80
87
  getWorkspaces?: GetWorkspacesRequest | undefined;
81
88
  setWindowBounds?: SetWindowBoundsRequest | undefined;
89
+ focusWindow?: FocusWindowRequest | undefined;
82
90
  }
83
91
  export interface Response {
84
92
  ping?: PingResponse | undefined;
@@ -88,12 +96,15 @@ export interface Response {
88
96
  getScreens?: GetScreensResponse | undefined;
89
97
  getWorkspaces?: GetWorkspacesResponse | undefined;
90
98
  setWindowBounds?: SetWindowBoundsResponse | undefined;
99
+ focusWindow?: FocusWindowResponse | undefined;
91
100
  }
92
101
  export declare const Window: MessageFns<Window>;
93
102
  export declare const Screen: MessageFns<Screen>;
94
103
  export declare const Workspace: MessageFns<Workspace>;
95
104
  export declare const PingRequest: MessageFns<PingRequest>;
96
105
  export declare const PingResponse: MessageFns<PingResponse>;
106
+ export declare const FocusWindowRequest: MessageFns<FocusWindowRequest>;
107
+ export declare const FocusWindowResponse: MessageFns<FocusWindowResponse>;
97
108
  export declare const GetActiveWindowRequest: MessageFns<GetActiveWindowRequest>;
98
109
  export declare const GetActiveWindowResponse: MessageFns<GetActiveWindowResponse>;
99
110
  export declare const GetWorkspacesRequest: MessageFns<GetWorkspacesRequest>;
@@ -5,42 +5,56 @@
5
5
  // protoc v6.32.1
6
6
  // source: wm.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.Response = exports.Request = exports.SetWindowBoundsResponse = exports.SetWindowBoundsRequest = exports.GetWindowsResponse = exports.GetWindowsRequest = exports.GetScreensResponse = exports.GetScreensRequest = exports.GetActiveWorkspaceWindowsResponse = exports.GetActiveWorkspaceWindowsRequest = exports.GetActiveWorkspaceResponse = exports.GetActiveWorkspaceRequest = exports.GetWorkspacesResponse = exports.GetWorkspacesRequest = exports.GetActiveWindowResponse = exports.GetActiveWindowRequest = exports.PingResponse = exports.PingRequest = exports.Workspace = exports.Screen = exports.Window = exports.protobufPackage = void 0;
8
+ exports.Response = exports.Request = exports.SetWindowBoundsResponse = exports.SetWindowBoundsRequest = exports.GetWindowsResponse = exports.GetWindowsRequest = exports.GetScreensResponse = exports.GetScreensRequest = exports.GetActiveWorkspaceWindowsResponse = exports.GetActiveWorkspaceWindowsRequest = exports.GetActiveWorkspaceResponse = exports.GetActiveWorkspaceRequest = exports.GetWorkspacesResponse = exports.GetWorkspacesRequest = exports.GetActiveWindowResponse = exports.GetActiveWindowRequest = exports.FocusWindowResponse = exports.FocusWindowRequest = exports.PingResponse = exports.PingRequest = exports.Workspace = exports.Screen = exports.Window = exports.protobufPackage = void 0;
9
9
  /* eslint-disable */
10
10
  const wire_1 = require("@bufbuild/protobuf/wire");
11
11
  const application_1 = require("./application");
12
12
  exports.protobufPackage = "proto.ext.wm";
13
13
  function createBaseWindow() {
14
- return { id: "", workspaceId: "", active: false, fullscreen: false, x: 0, y: 0, width: 0, height: 0, app: undefined };
14
+ return {
15
+ id: "",
16
+ title: "",
17
+ workspaceId: "",
18
+ active: false,
19
+ fullscreen: false,
20
+ x: 0,
21
+ y: 0,
22
+ width: 0,
23
+ height: 0,
24
+ app: undefined,
25
+ };
15
26
  }
16
27
  exports.Window = {
17
28
  encode(message, writer = new wire_1.BinaryWriter()) {
18
29
  if (message.id !== "") {
19
30
  writer.uint32(10).string(message.id);
20
31
  }
32
+ if (message.title !== "") {
33
+ writer.uint32(18).string(message.title);
34
+ }
21
35
  if (message.workspaceId !== "") {
22
- writer.uint32(18).string(message.workspaceId);
36
+ writer.uint32(26).string(message.workspaceId);
23
37
  }
24
38
  if (message.active !== false) {
25
- writer.uint32(24).bool(message.active);
39
+ writer.uint32(32).bool(message.active);
26
40
  }
27
41
  if (message.fullscreen !== false) {
28
- writer.uint32(32).bool(message.fullscreen);
42
+ writer.uint32(40).bool(message.fullscreen);
29
43
  }
30
44
  if (message.x !== 0) {
31
- writer.uint32(40).int32(message.x);
45
+ writer.uint32(48).int32(message.x);
32
46
  }
33
47
  if (message.y !== 0) {
34
- writer.uint32(48).int32(message.y);
48
+ writer.uint32(56).int32(message.y);
35
49
  }
36
50
  if (message.width !== 0) {
37
- writer.uint32(56).int32(message.width);
51
+ writer.uint32(64).int32(message.width);
38
52
  }
39
53
  if (message.height !== 0) {
40
- writer.uint32(64).int32(message.height);
54
+ writer.uint32(72).int32(message.height);
41
55
  }
42
56
  if (message.app !== undefined) {
43
- application_1.Application.encode(message.app, writer.uint32(74).fork()).join();
57
+ application_1.Application.encode(message.app, writer.uint32(82).fork()).join();
44
58
  }
45
59
  return writer;
46
60
  },
@@ -62,53 +76,60 @@ exports.Window = {
62
76
  if (tag !== 18) {
63
77
  break;
64
78
  }
65
- message.workspaceId = reader.string();
79
+ message.title = reader.string();
66
80
  continue;
67
81
  }
68
82
  case 3: {
69
- if (tag !== 24) {
83
+ if (tag !== 26) {
70
84
  break;
71
85
  }
72
- message.active = reader.bool();
86
+ message.workspaceId = reader.string();
73
87
  continue;
74
88
  }
75
89
  case 4: {
76
90
  if (tag !== 32) {
77
91
  break;
78
92
  }
79
- message.fullscreen = reader.bool();
93
+ message.active = reader.bool();
80
94
  continue;
81
95
  }
82
96
  case 5: {
83
97
  if (tag !== 40) {
84
98
  break;
85
99
  }
86
- message.x = reader.int32();
100
+ message.fullscreen = reader.bool();
87
101
  continue;
88
102
  }
89
103
  case 6: {
90
104
  if (tag !== 48) {
91
105
  break;
92
106
  }
93
- message.y = reader.int32();
107
+ message.x = reader.int32();
94
108
  continue;
95
109
  }
96
110
  case 7: {
97
111
  if (tag !== 56) {
98
112
  break;
99
113
  }
100
- message.width = reader.int32();
114
+ message.y = reader.int32();
101
115
  continue;
102
116
  }
103
117
  case 8: {
104
118
  if (tag !== 64) {
105
119
  break;
106
120
  }
107
- message.height = reader.int32();
121
+ message.width = reader.int32();
108
122
  continue;
109
123
  }
110
124
  case 9: {
111
- if (tag !== 74) {
125
+ if (tag !== 72) {
126
+ break;
127
+ }
128
+ message.height = reader.int32();
129
+ continue;
130
+ }
131
+ case 10: {
132
+ if (tag !== 82) {
112
133
  break;
113
134
  }
114
135
  message.app = application_1.Application.decode(reader, reader.uint32());
@@ -125,6 +146,7 @@ exports.Window = {
125
146
  fromJSON(object) {
126
147
  return {
127
148
  id: isSet(object.id) ? globalThis.String(object.id) : "",
149
+ title: isSet(object.title) ? globalThis.String(object.title) : "",
128
150
  workspaceId: isSet(object.workspaceId) ? globalThis.String(object.workspaceId) : "",
129
151
  active: isSet(object.active) ? globalThis.Boolean(object.active) : false,
130
152
  fullscreen: isSet(object.fullscreen) ? globalThis.Boolean(object.fullscreen) : false,
@@ -140,6 +162,9 @@ exports.Window = {
140
162
  if (message.id !== "") {
141
163
  obj.id = message.id;
142
164
  }
165
+ if (message.title !== "") {
166
+ obj.title = message.title;
167
+ }
143
168
  if (message.workspaceId !== "") {
144
169
  obj.workspaceId = message.workspaceId;
145
170
  }
@@ -172,6 +197,7 @@ exports.Window = {
172
197
  fromPartial(object) {
173
198
  const message = createBaseWindow();
174
199
  message.id = object.id ?? "";
200
+ message.title = object.title ?? "";
175
201
  message.workspaceId = object.workspaceId ?? "";
176
202
  message.active = object.active ?? false;
177
203
  message.fullscreen = object.fullscreen ?? false;
@@ -542,6 +568,108 @@ exports.PingResponse = {
542
568
  return message;
543
569
  },
544
570
  };
571
+ function createBaseFocusWindowRequest() {
572
+ return { id: "" };
573
+ }
574
+ exports.FocusWindowRequest = {
575
+ encode(message, writer = new wire_1.BinaryWriter()) {
576
+ if (message.id !== "") {
577
+ writer.uint32(10).string(message.id);
578
+ }
579
+ return writer;
580
+ },
581
+ decode(input, length) {
582
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
583
+ const end = length === undefined ? reader.len : reader.pos + length;
584
+ const message = createBaseFocusWindowRequest();
585
+ while (reader.pos < end) {
586
+ const tag = reader.uint32();
587
+ switch (tag >>> 3) {
588
+ case 1: {
589
+ if (tag !== 10) {
590
+ break;
591
+ }
592
+ message.id = reader.string();
593
+ continue;
594
+ }
595
+ }
596
+ if ((tag & 7) === 4 || tag === 0) {
597
+ break;
598
+ }
599
+ reader.skip(tag & 7);
600
+ }
601
+ return message;
602
+ },
603
+ fromJSON(object) {
604
+ return { id: isSet(object.id) ? globalThis.String(object.id) : "" };
605
+ },
606
+ toJSON(message) {
607
+ const obj = {};
608
+ if (message.id !== "") {
609
+ obj.id = message.id;
610
+ }
611
+ return obj;
612
+ },
613
+ create(base) {
614
+ return exports.FocusWindowRequest.fromPartial(base ?? {});
615
+ },
616
+ fromPartial(object) {
617
+ const message = createBaseFocusWindowRequest();
618
+ message.id = object.id ?? "";
619
+ return message;
620
+ },
621
+ };
622
+ function createBaseFocusWindowResponse() {
623
+ return { ok: false };
624
+ }
625
+ exports.FocusWindowResponse = {
626
+ encode(message, writer = new wire_1.BinaryWriter()) {
627
+ if (message.ok !== false) {
628
+ writer.uint32(8).bool(message.ok);
629
+ }
630
+ return writer;
631
+ },
632
+ decode(input, length) {
633
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
634
+ const end = length === undefined ? reader.len : reader.pos + length;
635
+ const message = createBaseFocusWindowResponse();
636
+ while (reader.pos < end) {
637
+ const tag = reader.uint32();
638
+ switch (tag >>> 3) {
639
+ case 1: {
640
+ if (tag !== 8) {
641
+ break;
642
+ }
643
+ message.ok = reader.bool();
644
+ continue;
645
+ }
646
+ }
647
+ if ((tag & 7) === 4 || tag === 0) {
648
+ break;
649
+ }
650
+ reader.skip(tag & 7);
651
+ }
652
+ return message;
653
+ },
654
+ fromJSON(object) {
655
+ return { ok: isSet(object.ok) ? globalThis.Boolean(object.ok) : false };
656
+ },
657
+ toJSON(message) {
658
+ const obj = {};
659
+ if (message.ok !== false) {
660
+ obj.ok = message.ok;
661
+ }
662
+ return obj;
663
+ },
664
+ create(base) {
665
+ return exports.FocusWindowResponse.fromPartial(base ?? {});
666
+ },
667
+ fromPartial(object) {
668
+ const message = createBaseFocusWindowResponse();
669
+ message.ok = object.ok ?? false;
670
+ return message;
671
+ },
672
+ };
545
673
  function createBaseGetActiveWindowRequest() {
546
674
  return {};
547
675
  }
@@ -1212,6 +1340,7 @@ function createBaseRequest() {
1212
1340
  getScreens: undefined,
1213
1341
  getWorkspaces: undefined,
1214
1342
  setWindowBounds: undefined,
1343
+ focusWindow: undefined,
1215
1344
  };
1216
1345
  }
1217
1346
  exports.Request = {
@@ -1237,6 +1366,9 @@ exports.Request = {
1237
1366
  if (message.setWindowBounds !== undefined) {
1238
1367
  exports.SetWindowBoundsRequest.encode(message.setWindowBounds, writer.uint32(58).fork()).join();
1239
1368
  }
1369
+ if (message.focusWindow !== undefined) {
1370
+ exports.FocusWindowRequest.encode(message.focusWindow, writer.uint32(66).fork()).join();
1371
+ }
1240
1372
  return writer;
1241
1373
  },
1242
1374
  decode(input, length) {
@@ -1295,6 +1427,13 @@ exports.Request = {
1295
1427
  message.setWindowBounds = exports.SetWindowBoundsRequest.decode(reader, reader.uint32());
1296
1428
  continue;
1297
1429
  }
1430
+ case 8: {
1431
+ if (tag !== 66) {
1432
+ break;
1433
+ }
1434
+ message.focusWindow = exports.FocusWindowRequest.decode(reader, reader.uint32());
1435
+ continue;
1436
+ }
1298
1437
  }
1299
1438
  if ((tag & 7) === 4 || tag === 0) {
1300
1439
  break;
@@ -1318,6 +1457,7 @@ exports.Request = {
1318
1457
  setWindowBounds: isSet(object.setWindowBounds)
1319
1458
  ? exports.SetWindowBoundsRequest.fromJSON(object.setWindowBounds)
1320
1459
  : undefined,
1460
+ focusWindow: isSet(object.focusWindow) ? exports.FocusWindowRequest.fromJSON(object.focusWindow) : undefined,
1321
1461
  };
1322
1462
  },
1323
1463
  toJSON(message) {
@@ -1343,6 +1483,9 @@ exports.Request = {
1343
1483
  if (message.setWindowBounds !== undefined) {
1344
1484
  obj.setWindowBounds = exports.SetWindowBoundsRequest.toJSON(message.setWindowBounds);
1345
1485
  }
1486
+ if (message.focusWindow !== undefined) {
1487
+ obj.focusWindow = exports.FocusWindowRequest.toJSON(message.focusWindow);
1488
+ }
1346
1489
  return obj;
1347
1490
  },
1348
1491
  create(base) {
@@ -1371,6 +1514,9 @@ exports.Request = {
1371
1514
  message.setWindowBounds = (object.setWindowBounds !== undefined && object.setWindowBounds !== null)
1372
1515
  ? exports.SetWindowBoundsRequest.fromPartial(object.setWindowBounds)
1373
1516
  : undefined;
1517
+ message.focusWindow = (object.focusWindow !== undefined && object.focusWindow !== null)
1518
+ ? exports.FocusWindowRequest.fromPartial(object.focusWindow)
1519
+ : undefined;
1374
1520
  return message;
1375
1521
  },
1376
1522
  };
@@ -1383,6 +1529,7 @@ function createBaseResponse() {
1383
1529
  getScreens: undefined,
1384
1530
  getWorkspaces: undefined,
1385
1531
  setWindowBounds: undefined,
1532
+ focusWindow: undefined,
1386
1533
  };
1387
1534
  }
1388
1535
  exports.Response = {
@@ -1408,6 +1555,9 @@ exports.Response = {
1408
1555
  if (message.setWindowBounds !== undefined) {
1409
1556
  exports.SetWindowBoundsResponse.encode(message.setWindowBounds, writer.uint32(58).fork()).join();
1410
1557
  }
1558
+ if (message.focusWindow !== undefined) {
1559
+ exports.FocusWindowResponse.encode(message.focusWindow, writer.uint32(66).fork()).join();
1560
+ }
1411
1561
  return writer;
1412
1562
  },
1413
1563
  decode(input, length) {
@@ -1466,6 +1616,13 @@ exports.Response = {
1466
1616
  message.setWindowBounds = exports.SetWindowBoundsResponse.decode(reader, reader.uint32());
1467
1617
  continue;
1468
1618
  }
1619
+ case 8: {
1620
+ if (tag !== 66) {
1621
+ break;
1622
+ }
1623
+ message.focusWindow = exports.FocusWindowResponse.decode(reader, reader.uint32());
1624
+ continue;
1625
+ }
1469
1626
  }
1470
1627
  if ((tag & 7) === 4 || tag === 0) {
1471
1628
  break;
@@ -1489,6 +1646,7 @@ exports.Response = {
1489
1646
  setWindowBounds: isSet(object.setWindowBounds)
1490
1647
  ? exports.SetWindowBoundsResponse.fromJSON(object.setWindowBounds)
1491
1648
  : undefined,
1649
+ focusWindow: isSet(object.focusWindow) ? exports.FocusWindowResponse.fromJSON(object.focusWindow) : undefined,
1492
1650
  };
1493
1651
  },
1494
1652
  toJSON(message) {
@@ -1514,6 +1672,9 @@ exports.Response = {
1514
1672
  if (message.setWindowBounds !== undefined) {
1515
1673
  obj.setWindowBounds = exports.SetWindowBoundsResponse.toJSON(message.setWindowBounds);
1516
1674
  }
1675
+ if (message.focusWindow !== undefined) {
1676
+ obj.focusWindow = exports.FocusWindowResponse.toJSON(message.focusWindow);
1677
+ }
1517
1678
  return obj;
1518
1679
  },
1519
1680
  create(base) {
@@ -1542,6 +1703,9 @@ exports.Response = {
1542
1703
  message.setWindowBounds = (object.setWindowBounds !== undefined && object.setWindowBounds !== null)
1543
1704
  ? exports.SetWindowBoundsResponse.fromPartial(object.setWindowBounds)
1544
1705
  : undefined;
1706
+ message.focusWindow = (object.focusWindow !== undefined && object.focusWindow !== null)
1707
+ ? exports.FocusWindowResponse.fromPartial(object.focusWindow)
1708
+ : undefined;
1545
1709
  return message;
1546
1710
  },
1547
1711
  };
@@ -4,21 +4,36 @@ import * as wm from "./proto/wm";
4
4
  * Access Vicinae's window management features.
5
5
  *
6
6
  * @remarks
7
- * Window management features are available to a different degree depending on what environment vicinae runs
8
- * in.
7
+ * Window management support varies a lot depending on the environment.
8
+ * Right now it is pretty well supported on almost all linux desktop environments except KDE.
9
9
  *
10
10
  * @example
11
11
  * ```typescript
12
12
  * import { WindowManagement } from '@vicinae/api';
13
13
  *
14
- * const windows = await WindowManagement.getWindows();
14
+ * const wins = await WindowManagement.getWindows();
15
+ * const browserWindow = wins.find(w => w.application?.name?.includes('firefox'));
16
+ *
17
+ * if (browserWindow) {
18
+ * await browserWindow.focus();
19
+ * }
15
20
  * ```
21
+ *
16
22
  * @category Window Management
17
23
  * @public
18
24
  */
19
25
  export declare namespace WindowManagement {
26
+ /**
27
+ * A window as defined by the windowing system in use.
28
+ * A window can be optionally tied to an application or a workspace.
29
+ */
20
30
  type Window = {
21
31
  id: string;
32
+ title: string;
33
+ /**
34
+ * Whether this window is currently active.
35
+ * This is usually the window that currently owns focus.
36
+ */
22
37
  active: boolean;
23
38
  bounds: {
24
39
  position: {
@@ -30,8 +45,20 @@ export declare namespace WindowManagement {
30
45
  width: number;
31
46
  };
32
47
  };
48
+ /**
49
+ * The ID of the workspace this window belongs to, if applicable in the context
50
+ * of the current window manager.
51
+ */
33
52
  workspaceId?: string;
53
+ /**
54
+ * The application this window belongs to, if any.
55
+ */
34
56
  application?: Application;
57
+ /**
58
+ * Request that the window manager focuses this window.
59
+ * @see {@link focusWindow}
60
+ */
61
+ focus: () => Promise<boolean>;
35
62
  };
36
63
  type Workspace = {
37
64
  id: string;
@@ -43,6 +70,13 @@ export declare namespace WindowManagement {
43
70
  * A screen, physical or virtual, attached to this computer.
44
71
  */
45
72
  type Screen = {
73
+ /**
74
+ * Name assigned by the windowing system to that screen.
75
+ *
76
+ * In Wayland environments for instance, the name is set to something like `DP-1`, `DP-2`, `e-DP1`...
77
+ *
78
+ * @remarks The name is not guaranteed to remain stable but is usually stable enough to uniquely identify a screen.
79
+ */
46
80
  name: string;
47
81
  /**
48
82
  * Name of the screen's manufacturer.
@@ -64,8 +98,22 @@ export declare namespace WindowManagement {
64
98
  };
65
99
  };
66
100
  };
67
- function ping(): Promise<boolean>;
68
101
  function getWindows(options?: wm.GetWindowsRequest): Promise<WindowManagement.Window[]>;
102
+ /**
103
+ * Focus `window`.
104
+ *
105
+ * @remarks
106
+ * Window objects have a {@link Window.focus} method that can be used to achieve the same thing on a specific window directly.
107
+ *
108
+ * @param window - the window to focus. You may want to make sure this window still exists when you request focus.
109
+ *
110
+ * @return `true` if the window was focused, `false` otherwise.
111
+ * A window may not have been focused because it doesn't accept focus (e.g some layer shell surfaces)
112
+ * or simply because it doesn't exist anymore.
113
+ *
114
+ * @see {@link Window.focus}
115
+ */
116
+ function focusWindow(window: Window): Promise<boolean>;
69
117
  /**
70
118
  * Return the list of screens (physical and virtual) currently attached to the computer.
71
119
  */
@@ -13,6 +13,7 @@ const transformWorkspace = (proto) => {
13
13
  const transformWindow = (proto) => {
14
14
  return {
15
15
  id: proto.id,
16
+ title: proto.title,
16
17
  workspaceId: proto.workspaceId,
17
18
  active: proto.active,
18
19
  bounds: {
@@ -20,36 +21,61 @@ const transformWindow = (proto) => {
20
21
  size: { width: proto.width, height: proto.height },
21
22
  },
22
23
  application: proto.app,
24
+ focus() {
25
+ return WindowManagement.focusWindow(this);
26
+ },
23
27
  };
24
28
  };
25
29
  /**
26
30
  * Access Vicinae's window management features.
27
31
  *
28
32
  * @remarks
29
- * Window management features are available to a different degree depending on what environment vicinae runs
30
- * in.
33
+ * Window management support varies a lot depending on the environment.
34
+ * Right now it is pretty well supported on almost all linux desktop environments except KDE.
31
35
  *
32
36
  * @example
33
37
  * ```typescript
34
38
  * import { WindowManagement } from '@vicinae/api';
35
39
  *
36
- * const windows = await WindowManagement.getWindows();
40
+ * const wins = await WindowManagement.getWindows();
41
+ * const browserWindow = wins.find(w => w.application?.name?.includes('firefox'));
42
+ *
43
+ * if (browserWindow) {
44
+ * await browserWindow.focus();
45
+ * }
37
46
  * ```
47
+ *
38
48
  * @category Window Management
39
49
  * @public
40
50
  */
41
51
  var WindowManagement;
42
52
  (function (WindowManagement) {
43
- async function ping() {
44
- const res = await bus_1.bus.turboRequest("wm.ping", {});
45
- return res.unwrap().ok;
46
- }
47
- WindowManagement.ping = ping;
48
53
  async function getWindows(options = {}) {
49
54
  const res = await bus_1.bus.turboRequest("wm.getWindows", options);
50
55
  return res.unwrap().windows.map(transformWindow);
51
56
  }
52
57
  WindowManagement.getWindows = getWindows;
58
+ /**
59
+ * Focus `window`.
60
+ *
61
+ * @remarks
62
+ * Window objects have a {@link Window.focus} method that can be used to achieve the same thing on a specific window directly.
63
+ *
64
+ * @param window - the window to focus. You may want to make sure this window still exists when you request focus.
65
+ *
66
+ * @return `true` if the window was focused, `false` otherwise.
67
+ * A window may not have been focused because it doesn't accept focus (e.g some layer shell surfaces)
68
+ * or simply because it doesn't exist anymore.
69
+ *
70
+ * @see {@link Window.focus}
71
+ */
72
+ async function focusWindow(window) {
73
+ const res = await bus_1.bus.turboRequest("wm.focusWindow", {
74
+ id: window.id,
75
+ });
76
+ return res.unwrap().ok;
77
+ }
78
+ WindowManagement.focusWindow = focusWindow;
53
79
  /**
54
80
  * Return the list of screens (physical and virtual) currently attached to the computer.
55
81
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicinae/api",
3
- "version": "0.16.6",
3
+ "version": "0.16.8",
4
4
  "description": "TypeScript SDK to build Vicinae extensions",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",