@domicile-desktop/system-backlight 0.0.0-alpha-44d0983a58ce → 0.0.0-alpha-56dd6c187f4e

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/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # @domicile-desktop/system-backlight
2
2
 
3
- Screen brightness for a Domicile shell, on the system calls of
4
- [`@domicile-desktop/sdk/system`](/packages/chrome-sdk/src/system.ts). See
3
+ Screen brightness for a Domicile shell, on the `files`, `processes` and `dbus`
4
+ namespaces of [`desktop(domicile)`](/packages/chrome-sdk/src/desktop/desktop.ts). See
5
5
  [SHELL-SYSTEM-ACCESS.md](/docs/SHELL-SYSTEM-ACCESS.md).
6
6
 
7
7
  ## Usage
8
8
 
9
9
  ```ts
10
- import { system } from "@domicile-desktop/sdk/system";
10
+ import { desktop } from "@domicile-desktop/sdk/desktop/desktop";
11
11
  import { brightnessSetter } from "@domicile-desktop/system-backlight/set-brightness";
12
12
  import { watchBrightness } from "@domicile-desktop/system-backlight/watch-brightness";
13
13
 
14
- const host = system(domicile);
14
+ const host = desktop(domicile);
15
15
  const watch = await watchBrightness(host, (level) => show(level));
16
16
  const set = brightnessSetter(host);
17
17
  await set(0.5);
@@ -1,7 +1,10 @@
1
1
  import type { Option, Result } from "@cprussin/option-result";
2
- import type { System, SystemError } from "@domicile-desktop/sdk/system";
2
+ import type { Files } from "@domicile-desktop/sdk/desktop/files";
3
+ import type { SystemError } from "@domicile-desktop/sdk/system";
3
4
  /** The calls {@link readBacklight} makes. */
4
- export type SysfsHost = Pick<System, "readDir" | "readTextFile">;
5
+ export type SysfsHost = {
6
+ readonly files: Pick<Files, "readDir" | "readText">;
7
+ };
5
8
  /** One backlight device's current and maximum raw brightness. */
6
9
  export type Backlight = {
7
10
  /** The name under `/sys/class/backlight`, which logind takes. */
@@ -18,7 +18,7 @@ const FILES = ["type", "max_brightness", "brightness"];
18
18
  * Skips a device whose files are missing or not numbers, or whose maximum is
19
19
  * zero.
20
20
  */
21
- export const readBacklight = async (host) => (await host.readDir(BACKLIGHT)).match({
21
+ export const readBacklight = async (host) => (await host.files.readDir(BACKLIGHT)).match({
22
22
  Err: async (error) => error.kind === SystemErrorKind.NotFound ? Ok(None()) : Err(error),
23
23
  Ok: async (entries) => collected(await Promise.all(entries
24
24
  .map(({ name }) => name)
@@ -45,7 +45,7 @@ const readOne = async (host, device) => collected(await Promise.all(FILES.map((f
45
45
  : None();
46
46
  });
47
47
  /** A file of `device`, trimmed, or `None` if it is missing. */
48
- const readFile = async (host, device, file) => (await host.readTextFile(`${BACKLIGHT}/${device}/${file}`)).match({
48
+ const readFile = async (host, device, file) => (await host.files.readText(`${BACKLIGHT}/${device}/${file}`)).match({
49
49
  Err: (error) => error.kind === SystemErrorKind.NotFound ? Ok(None()) : Err(error),
50
50
  Ok: (text) => Ok(Some(text.trim())),
51
51
  });
@@ -1,5 +1,6 @@
1
1
  import type { Result } from "@cprussin/option-result";
2
- import type { System, SystemError } from "@domicile-desktop/sdk/system";
2
+ import type { Dbus } from "@domicile-desktop/sdk/desktop/dbus";
3
+ import type { SystemError } from "@domicile-desktop/sdk/system";
3
4
  import type { SysfsHost } from "./read-backlight";
4
5
  export declare enum SetOutcome {
5
6
  /** logind set it. */
@@ -9,7 +10,9 @@ export declare enum SetOutcome {
9
10
  NoBacklight = 2
10
11
  }
11
12
  /** The calls {@link brightnessSetter} makes. */
12
- export type SetterHost = SysfsHost & Pick<System, "dbusCall">;
13
+ export type SetterHost = SysfsHost & {
14
+ readonly dbus: Pick<Dbus, "call">;
15
+ };
13
16
  /** Sets the backlight to a level from 0 to 1, and says how it went. */
14
17
  export type SetBrightness = (level: number) => Promise<Result<SetOutcome, SystemError>>;
15
18
  /**
@@ -60,7 +60,7 @@ const sendFrom = async (host, queue, level) => {
60
60
  };
61
61
  const send = async (host, level) => (await readBacklight(host)).andThenAsync(async (read) => read.match({
62
62
  None: async () => Ok(SetOutcome.NoBacklight),
63
- Some: async (backlight) => (await host.dbusCall({
63
+ Some: async (backlight) => (await host.dbus.call({
64
64
  body: ["backlight", backlight.device, rawFor(backlight, level)],
65
65
  bus: Bus.System,
66
66
  destination: "org.freedesktop.login1",
@@ -1,8 +1,11 @@
1
1
  import type { Result } from "@cprussin/option-result";
2
- import type { System, SystemError } from "@domicile-desktop/sdk/system";
2
+ import type { Processes } from "@domicile-desktop/sdk/desktop/processes";
3
+ import type { SystemError } from "@domicile-desktop/sdk/system";
3
4
  import type { SysfsHost } from "./read-backlight";
4
5
  /** The calls {@link watchBrightness} makes. */
5
- export type WatchHost = SysfsHost & Pick<System, "spawn">;
6
+ export type WatchHost = SysfsHost & {
7
+ readonly processes: Pick<Processes, "spawn">;
8
+ };
6
9
  export type BrightnessWatch = {
7
10
  stop: () => void;
8
11
  /** `Ok` after {@link BrightnessWatch.stop}, `Err` if the watch broke. */
@@ -27,7 +27,7 @@ const BACKSTOP_MS = 120_000;
27
27
  * and reads then. See "A compositor restart" in
28
28
  * docs/architecture/ENGINE-FORK.md.
29
29
  */
30
- export const watchBrightness = async (host, onLevel, every = everyInterval) => (await host.spawn(UDEVADM)).map((udevadm) => {
30
+ export const watchBrightness = async (host, onLevel, every = everyInterval) => (await host.processes.spawn(UDEVADM)).map((udevadm) => {
31
31
  const watch = {
32
32
  failure: undefined,
33
33
  reading: Promise.resolve(),
@@ -146,7 +146,7 @@ const eachLine = async (stream, onLine) => {
146
146
  /** udevadm under the next compositor, past any that exits before it starts. */
147
147
  const respawn = async (host) => {
148
148
  for (;;) {
149
- const next = await host.spawn(UDEVADM);
149
+ const next = await host.processes.spawn(UDEVADM);
150
150
  if (!isGone(next)) {
151
151
  return next;
152
152
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/sdk": "0.0.0-alpha-44d0983a58ce",
4
+ "@domicile-desktop/sdk": "0.0.0-alpha-56dd6c187f4e",
5
5
  "zod": "^4.5.4"
6
6
  },
7
7
  "description": "Screen brightness for a Domicile shell: reads /sys/class/backlight, watches it and sets it through logind, on @domicile-desktop/sdk/system.",
@@ -49,5 +49,5 @@
49
49
  "test:unit": "bun test"
50
50
  },
51
51
  "type": "module",
52
- "version": "0.0.0-alpha-44d0983a58ce"
52
+ "version": "0.0.0-alpha-56dd6c187f4e"
53
53
  }