betterdisplaycli 0.1.4 → 0.1.7
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/Makefile +1 -1
- package/bun.lock +2 -2
- package/package.json +2 -2
- package/src/get.test.ts +19 -1
- package/src/get.ts +37 -21
package/Makefile
CHANGED
package/bun.lock
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"workspaces": {
|
|
5
5
|
"": {
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"printable-shell-command": "^2.3
|
|
7
|
+
"printable-shell-command": "^2.6.3",
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@biomejs/biome": "^2.3.4",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
|
|
100
100
|
"path-class": ["path-class@0.6.1", "", { "dependencies": { "@types/node": "^24.7.1", "xdg-basedir": "^5.1.0" } }, "sha512-38ZYmRh38kFSKivJCHk9S4ZHOK4Wf6ocxHfYBdDmVN7GWVOXrYsxwMBQpjhGyPNBdiPo4W3X91x2TzGmxHBlUg=="],
|
|
101
101
|
|
|
102
|
-
"printable-shell-command": ["printable-shell-command@2.3
|
|
102
|
+
"printable-shell-command": ["printable-shell-command@2.6.3", "", { "dependencies": { "path-class": ">=0.6.1", "type-fest": ">=5.1.0" }, "optionalDependencies": { "@types/bun": "^1.2.20", "@types/node": "^24.2.0" } }, "sha512-u49zQsdil1clG2RKs+PQvoU64FfRXziMi8cTjrL7Cv92q1eYwyNnHM9PAux0qIme2ucWxn3gIYshkXhyS54y5A=="],
|
|
103
103
|
|
|
104
104
|
"tagged-tag": ["tagged-tag@1.0.0", "", {}, "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng=="],
|
|
105
105
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "betterdisplaycli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "TypeScript bindings for `betterdisplaycli`.",
|
|
5
5
|
"author": "Lucas Garron <code@garron.net>",
|
|
6
6
|
"exports": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"printable-shell-command": "^2.3
|
|
12
|
+
"printable-shell-command": "^2.6.3"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@biomejs/biome": "^2.3.4",
|
package/src/get.test.ts
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
1
|
+
import { expect, spyOn, test } from "bun:test";
|
|
2
|
+
import { stderr } from "node:process";
|
|
2
3
|
import { getAllDevices } from "./get";
|
|
3
4
|
|
|
5
|
+
const stderrMock = spyOn(stderr, "write");
|
|
6
|
+
|
|
4
7
|
test("getAllDevices", async () => {
|
|
5
8
|
const numConnected = (await getAllDevices({ ignoreDisplayGroups: true }))
|
|
6
9
|
.length;
|
|
7
10
|
expect(numConnected).toBeTypeOf("number");
|
|
11
|
+
expect(stderrMock.mock.calls.slice(-2)).toEqual([
|
|
12
|
+
[
|
|
13
|
+
"\u001B[90m\u001B[1mbetterdisplaycli get --identifiers\u001B[22m\u001B[39m",
|
|
14
|
+
],
|
|
15
|
+
["\n"],
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("getAllDevices quiet", async () => {
|
|
20
|
+
stderrMock.mockReset();
|
|
21
|
+
const numConnected = (
|
|
22
|
+
await getAllDevices({ ignoreDisplayGroups: true, quiet: true })
|
|
23
|
+
).length;
|
|
24
|
+
expect(numConnected).toBeTypeOf("number");
|
|
25
|
+
expect(stderrMock.mock.calls).toEqual([]);
|
|
8
26
|
});
|
package/src/get.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { styleText } from "node:util";
|
|
2
1
|
import { PrintableShellCommand } from "printable-shell-command";
|
|
3
2
|
import {
|
|
4
3
|
type Device,
|
|
@@ -8,21 +7,36 @@ import {
|
|
|
8
7
|
type VirtualScreen,
|
|
9
8
|
} from "./Device";
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
interface QuietOption {
|
|
11
|
+
quiet?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function print(
|
|
15
|
+
command: PrintableShellCommand,
|
|
16
|
+
printOptions?: Parameters<PrintableShellCommand["print"]>[0],
|
|
17
|
+
quietOptions?: QuietOption,
|
|
18
|
+
): PrintableShellCommand {
|
|
19
|
+
if (!quietOptions?.quiet) {
|
|
20
|
+
command.print(printOptions);
|
|
21
|
+
}
|
|
22
|
+
return command;
|
|
23
|
+
}
|
|
15
24
|
|
|
16
|
-
export async function getAllDevices(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
export async function getAllDevices(
|
|
26
|
+
options?: {
|
|
27
|
+
ignoreDisplayGroups?: true;
|
|
28
|
+
} & QuietOption,
|
|
29
|
+
): Promise<(Display | VirtualScreen)[]>;
|
|
30
|
+
export async function getAllDevices(
|
|
31
|
+
options?: {
|
|
32
|
+
ignoreDisplayGroups?: boolean;
|
|
33
|
+
} & QuietOption,
|
|
34
|
+
): Promise<Device[]> {
|
|
35
|
+
const jsonStream = await print(
|
|
36
|
+
new PrintableShellCommand("betterdisplaycli", [["get", "--identifiers"]]),
|
|
37
|
+
{ argumentLineWrapping: "inline" },
|
|
38
|
+
options,
|
|
39
|
+
)
|
|
26
40
|
.stdout()
|
|
27
41
|
.text();
|
|
28
42
|
const deviceInfos: DeviceInfo[] = JSON.parse(`[${jsonStream}]`);
|
|
@@ -36,10 +50,12 @@ export async function getAllDevices(options?: {
|
|
|
36
50
|
});
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
export async function connectAllDisplays(): Promise<void> {
|
|
40
|
-
await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
export async function connectAllDisplays(options: QuietOption): Promise<void> {
|
|
54
|
+
await print(
|
|
55
|
+
new PrintableShellCommand("betterdisplaycli", [
|
|
56
|
+
["perform", "--connectAllDisplays"],
|
|
57
|
+
]),
|
|
58
|
+
{ argumentLineWrapping: "inline" },
|
|
59
|
+
options,
|
|
60
|
+
).spawnTransparently().success;
|
|
45
61
|
}
|