dsh-screensaver 0.3.0 → 0.4.0

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/LICENSE-ASSETS.md CHANGED
@@ -7,14 +7,14 @@
7
7
 
8
8
  | Path | What | License |
9
9
  | --- | --- | --- |
10
- | `themes/**` (every theme: `basic` Clock, `subspace` Subspace Jump, and future themes in this repo) | The theme's visual design and everything that draws it: HTML, CSS, scenes, shaders, animation, generated `index.html` | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) |
11
- | `docs/images/**`, `assets/icon.png` | Screenshots, plugin icon | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) |
10
+ | `themes/**` (every theme: `basic` Clock, `subspace` Subspace Jump, `magic-tower` Arcane Study, and future themes in this repo) | The theme's visual design and everything that draws it: HTML, CSS, scenes, shaders, animation, generated `index.html` | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) |
11
+ | `docs/images/**`, `assets/icon.png` | Screenshots, demo GIFs, plugin icon | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) |
12
12
  | Everything else: `app/`, `lib/`, `bin/`, `native/`, `test/`, docs text | The screen saver engine, dsh plugin, Touch ID helper, session detection, theme API | [MIT](LICENSE) |
13
13
 
14
14
  | 路径 | 内容 | 授权 |
15
15
  | --- | --- | --- |
16
- | `themes/**`(本仓库所有主题:基础版「时钟」、「亚空间跃迁」,以及以后加进来的) | 主题的视觉设计和画出它的一切:HTML、CSS、场景、着色器、动画、打包出来的 `index.html` | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans) |
17
- | `docs/images/**`、`assets/icon.png` | 截图、插件图标 | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans) |
16
+ | `themes/**`(本仓库所有主题:基础版「时钟」、「亚空间跃迁」、「魔法书斋」,以及以后加进来的) | 主题的视觉设计和画出它的一切:HTML、CSS、场景、着色器、动画、打包出来的 `index.html` | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans) |
17
+ | `docs/images/**`、`assets/icon.png` | 截图、演示动图、插件图标 | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans) |
18
18
  | 其余:`app/`、`lib/`、`bin/`、`native/`、`test/`、文档文字 | 屏保引擎、dsh 插件、Touch ID 小程序、会话识别、主题接口 | [MIT](LICENSE) |
19
19
 
20
20
  ## You may / 你可以
@@ -33,8 +33,8 @@
33
33
 
34
34
  These keep their own terms and are not covered by the CC license above:
35
35
 
36
- - **three.js** (bundled in `themes/subspace/index.html`): MIT, © three.js authors.
37
- - **DeepSeek Harness whale** (`themes/subspace/assets/dsh.svg`): MIT, © 2026 DeepSeek (`@deepseek-ai/dsh-web-frontend`).
36
+ - **three.js** (bundled in `themes/subspace/index.html` and `themes/magic-tower/index.html`): MIT, © three.js authors.
37
+ - **DeepSeek Harness whale** (`themes/subspace/assets/dsh.svg`, `themes/magic-tower/assets/dsh.svg`): MIT, © 2026 DeepSeek (`@deepseek-ai/dsh-web-frontend`).
38
38
  - **Claude mark** (`assets/claude.png`) and **Codex app icon** (`assets/codex.png`): trademarks of Anthropic and OpenAI.
39
39
  The DeepSeek whale is also a DeepSeek trademark. They are used only to identify which product a session belongs to.
40
40
  This project is not affiliated with or endorsed by these companies.
package/README.md CHANGED
@@ -9,13 +9,19 @@ running, waiting for your approval, finished or stopped.
9
9
  It is a [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh) plugin, and it also runs on its own
10
10
  with `npx`.
11
11
 
12
- [中文说明](README.zh-CN.md) · [llms.txt (summary for AI assistants)](llms.txt) · [Theme API](docs/themes.md) · [Visual assets license](LICENSE-ASSETS.md)
12
+ [中文说明](README.zh-CN.md) · [llms.txt (summary for AI assistants)](llms.txt) · [Theme API](docs/themes.md) · [Theme skill](skills/dsh-screensaver-theme/SKILL.md) · [Visual assets license](LICENSE-ASSETS.md)
13
13
 
14
14
  ![Subspace Jump theme: Claude Code, Codex and DeepSeek Harness sessions listed during a warp jump](docs/images/subspace.jpg)
15
15
 
16
- | Clock (built in) | Subspace Jump (built in) |
17
- | --- | --- |
18
- | ![Clock theme: a macOS-style lock screen with date, time, battery, Wi-Fi and "Touch ID or Enter Password"](docs/images/basic-zh.jpg) | A three.js warp tunnel (above): when agents are running it jumps into subspace and lists each session with its own product icon. Inside, it drifts between a nebula storm, a vortex of ocean waves and a tunnel of Gaussian splats. |
16
+ Subspace Jump and Arcane Study each have an idle scene for when nothing is running and a running scene for when your
17
+ agents are working, and switch between them by themselves. Each clip below is 3 s of one scene, the transition, then
18
+ 5 s of the other. Clock is a macOS-style lock screen with no scenes: only the time moves.
19
+
20
+ | | Agents start: idle → running | Agents finish: running → idle |
21
+ | --- | --- | --- |
22
+ | **Subspace Jump**<br>`subspace` | ![Subspace Jump: three suns in normal space, then the camera locks onto a portal and jumps into the subspace tunnel while sessions are listed on the left](docs/images/subspace-enter.gif) | ![Subspace Jump: all sessions finish, the tunnel ends and the camera drops back to the three suns](docs/images/subspace-exit.gif) |
23
+ | **Arcane Study**<br>`magic-tower` | ![Arcane Study: a knight reads by moonlight in a tower study, then the camera dives into the book through a rune portal and the knight climbs the tower stairs](docs/images/magic-tower-enter.gif) | ![Arcane Study: all sessions finish, a book flies to the camera and opens, and the scene returns to the moonlit study](docs/images/magic-tower-exit.gif) |
24
+ | **Clock**<br>`basic` | ![Clock theme at 19:00: a macOS-style lock screen with date, time, battery, Wi-Fi and "Touch ID or Enter Password"](docs/images/basic-start.jpg) | ![Clock theme at 19:42: the same lock screen, only the time has moved](docs/images/basic-finish.jpg) |
19
25
 
20
26
  ## Why not the macOS screen saver, the lock screen, or a wallpaper?
21
27
 
@@ -51,7 +57,7 @@ dsh plugin --profile web add dsh-screensaver
51
57
  Use `desktop` instead of `web` for the desktop app profile, then restart dsh. The first start downloads the Electron
52
58
  runtime (about 100 MB, once) and compiles the Touch ID helper if the Xcode Command Line Tools are installed.
53
59
 
54
- Both themes, Clock and Subspace Jump, ship inside this package; there is nothing else to install.
60
+ All three themes, Clock, Subspace Jump and Arcane Study, ship inside this package; there is nothing else to install.
55
61
 
56
62
  Want the latest unreleased code from GitHub instead of the npm release:
57
63
 
@@ -84,6 +90,7 @@ is used instead.
84
90
  | --- | --- |
85
91
  | `/screensaver` | Start with the default theme |
86
92
  | `/screensaver <theme>` | Start with a theme, e.g. `/screensaver subspace` |
93
+ | `/screensaver <theme> <theme> …` | A theme per screen, main screen first, e.g. `/screensaver magic-tower subspace` |
87
94
  | `/screensaver themes` | List installed themes |
88
95
  | `/screensaver lid` | Show lid-closed awake status |
89
96
  | `/screensaver lid authorize` | Allow lid-closed awake (asks for an admin password once; installs a sudoers rule that only allows `pmset -a disablesleep 0/1`) |
@@ -98,6 +105,7 @@ Add an entry to your profile's `~/.dsh/profiles/<profile>/cordis.patch.yml` (it
98
105
  - id: dsh-screensaver
99
106
  config:
100
107
  theme: subspace # default theme id
108
+ screens: [magic-tower, subspace] # optional: a theme per screen (see "Several screens" below)
101
109
  idleMinutes: 10 # start after 10 idle minutes; 0 = never (default)
102
110
  lidAwake: true # keep the Mac awake with the lid closed while the screen saver is up (default; false turns it off)
103
111
  shortcut: Control+Alt+Command+L # Electron accelerator; '' disables the shortcut
@@ -107,28 +115,61 @@ Standalone, the same fields live in `~/.dsh/plugins-data/dsh-screensaver/config.
107
115
 
108
116
  | Command | What it does |
109
117
  | --- | --- |
110
- | `dsh-screensaver setup` | Walk through lid-closed awake (authorizes it on the spot), the theme and idle start |
118
+ | `dsh-screensaver setup` | Walk through lid-closed awake (authorizes it on the spot), the theme, a theme per screen and idle start |
111
119
  | `dsh-screensaver config` | Show the settings and the file they are saved in |
112
- | `dsh-screensaver config <key> <value>` | Change one, e.g. `config lidAwake off`, `config idleMinutes 10` |
120
+ | `dsh-screensaver config <key> <value>` | Change one, e.g. `config lidAwake off`, `config idleMinutes 10`, `config screens magic-tower,subspace` |
113
121
  | `dsh-screensaver config unset <key>` | Back to the default |
114
122
  | `dsh-screensaver lid [status\|authorize\|revoke]` | Lid-closed awake authorization, same as `/screensaver lid` |
115
123
  | `dsh-screensaver themes` | List installed themes |
116
124
 
117
125
  `DSH_SCREENSAVER_CONFIG='{"theme":"subspace"}'` overrides the file for one run. A `--now` handed to a screen saver that is
118
- already running (for example the one inside dsh) brings its `lidAwake` along for that start when it sets one (in the file or the variable); otherwise the running one
126
+ already running (for example the one inside dsh) brings its `lidAwake` and `screens` along for that start when it sets them (in the file or the variable); otherwise the running one
119
127
  uses its own config.
120
128
 
129
+ ### Several screens
130
+
131
+ Every screen gets the same theme unless you set `screens`: a list of theme ids, one per screen. The first is the main
132
+ screen (the one with the menu bar), the rest go to the other screens from left to right (top to bottom when two share a
133
+ column), and screens beyond the end of the list use its last entry. `[magic-tower, subspace]` puts Arcane Study on the
134
+ main screen and Subspace Jump on every other one; `[magic-tower, subspace, basic]` gives a third screen the clock. A
135
+ screen plugged in while the screen saver is up gets its theme the same way. Naming one theme for a single start
136
+ (`--now subspace`, `/screensaver subspace`) uses it on every screen that time.
137
+
121
138
  ## Themes
122
139
 
123
140
  | Theme | id | Ships with | Shows agent sessions |
124
141
  | --- | --- | --- | --- |
125
142
  | Clock | `basic` | built in | No |
126
143
  | Subspace Jump | `subspace` | built in | Yes |
144
+ | Arcane Study | `magic-tower` | built in | Yes |
145
+
146
+ - **Subspace Jump**: three suns orbit in normal space; while agents run, the camera jumps into a warp tunnel that drifts
147
+ between a nebula storm, a vortex of ocean waves and a tunnel of Gaussian splats.
148
+ - **Arcane Study**: an HD-2D pixel scene. A knight reads by moonlight in a tower study; while agents run, the camera
149
+ dives into the book and the knight climbs the tower. Sessions are listed on a rune ledger, and the theme draws its own
150
+ status bar (with tonight's moon phase) and Touch ID ring in the same places as the shell.
127
151
 
128
- More themes are coming. Themes are visual works licensed CC BY-NC-SA 4.0 (no commercial use). A theme is a folder with an `index.html` (runs in a sandboxed iframe, draws only) and a
152
+ In every theme the session list is on the left, the date and time at the top right and the Touch ID hint at the bottom
153
+ centre, and all of them fade out after 30 s without input, leaving only the scene.
154
+
155
+ Themes are visual works licensed CC BY-NC-SA 4.0 (no commercial use). A theme is a folder with an `index.html` (runs in a sandboxed iframe, draws only) and a
129
156
  `saver.json`. Put your own in `~/.dsh/plugins-data/dsh-screensaver/themes/<id>/`, or publish it as an npm package with
130
157
  `"dsh-screensaver": { "theme": "." }` in its `package.json`. See [docs/themes.md](docs/themes.md).
131
158
 
159
+ ### Make your own theme
160
+
161
+ [`skills/dsh-screensaver-theme`](skills/dsh-screensaver-theme/SKILL.md) is an agent skill with the rules every theme
162
+ follows, whatever it looks like: an idle scene and a running scene with transitions, the session list, the status bar
163
+ and clock, Touch ID feedback, hiding after 30 s, secondary displays and battery, the `#demo` page, packaging, and a
164
+ script that records the two README GIFs. It leaves the art style entirely to you.
165
+
166
+ Copy the folder into `~/.claude/skills/` (or your project's `.claude/skills/`) for Claude Code, or point any coding
167
+ agent at `SKILL.md`, then describe your idea: "make a dsh-screensaver theme where…". Read the two reference themes in
168
+ `themes/` for working code.
169
+
170
+ New themes, wild ideas and improvements to the skill itself are all welcome: open a PR with your theme under `themes/`,
171
+ or an issue to pitch an idea. The skill is maintained together; if you hit a rule it doesn't cover, add it.
172
+
132
173
  ## Which agent sessions are detected
133
174
 
134
175
  Only themes that set `"sessions": true` receive sessions, and only while the screen saver is up. Everything is read from
@@ -188,7 +229,8 @@ git clone https://github.com/realRoc/dsh-screensaver && cd dsh-screensaver
188
229
  npm install
189
230
  npm test # vitest
190
231
  npm run now # try it
191
- npm run build:themes # rebuild themes/subspace/index.html after editing themes/subspace/src
232
+ npm run build:themes # rebuild themes/*/index.html after editing themes/*/src
233
+ node skills/dsh-screensaver-theme/scripts/record-gif.mjs … # record README GIFs; usage at the top of the script
192
234
  DSH_SCREENSAVER_DEBUG=1 npm run now # log page console messages
193
235
  ```
194
236
 
@@ -205,7 +247,8 @@ Pushing a `v*` tag runs [`.github/workflows/publish.yml`](.github/workflows/publ
205
247
 
206
248
  Code is MIT ([LICENSE](LICENSE)). All visual assets, meaning every theme under `themes/` and the screenshots under
207
249
  `docs/images/`, are **CC BY-NC-SA 4.0: no commercial use** ([LICENSE-ASSETS.md](LICENSE-ASSETS.md)). Third-party notices:
208
- [themes/subspace/THIRD_PARTY_NOTICES.md](themes/subspace/THIRD_PARTY_NOTICES.md).
250
+ [themes/subspace/THIRD_PARTY_NOTICES.md](themes/subspace/THIRD_PARTY_NOTICES.md),
251
+ [themes/magic-tower/THIRD_PARTY_NOTICES.md](themes/magic-tower/THIRD_PARTY_NOTICES.md).
209
252
 
210
253
  <!-- Keywords: screen saver for AI coding agents, keep Claude Code running when away, keep Codex running, prevent Mac sleep
211
254
  while an agent runs, macOS lock screen alternative, Touch ID screen saver, keep Mac awake with lid closed, caffeinate
package/README.zh-CN.md CHANGED
@@ -6,13 +6,18 @@ dsh-screensaver 就是为这种时候做的:样子跟 Mac 锁屏一样,回
6
6
 
7
7
  它是 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)插件,不装 dsh 也能用 `npx` 单独运行。
8
8
 
9
- [English](README.md) · [llms.txt(写给 AI 看的简介)](llms.txt) · [主题开发](docs/themes.md) · [视觉素材授权](LICENSE-ASSETS.md)
9
+ [English](README.md) · [llms.txt(写给 AI 看的简介)](llms.txt) · [主题开发](docs/themes.md) · [主题 skill](skills/dsh-screensaver-theme/SKILL.md) · [视觉素材授权](LICENSE-ASSETS.md)
10
10
 
11
11
  ![「亚空间跃迁」主题:跃迁途中列出正在运行的 Claude Code、Codex、DeepSeek Harness 会话](docs/images/subspace-zh.jpg)
12
12
 
13
- | 时钟(内置) | 亚空间跃迁(独立主题包) |
14
- | --- | --- |
15
- | ![「时钟」主题:仿 macOS 锁屏,日期时间、电池、Wi-Fi,底部一行「使用触控 ID 或输入密码」](docs/images/basic-zh.jpg) | 用 three.js 画的跃迁隧道(见上图)。有 agent 在跑就进入亚空间,左侧列出每个会话,用各家产品自己的图标区分。亚空间里在星云雷暴、浪涌龙卷、高斯粒子三种画风之间自然切换。 |
13
+ 亚空间跃迁和魔法书斋都有两幅画面:没有 agent 在跑时的静止画面,和 agent 在跑时的运动画面,会自己来回切换。
14
+ 下面每段动图都是一幅画面 3 秒、转场、再另一幅画面 5 秒。时钟是仿 macOS 锁屏,没有动画场景,只有时间在走。
15
+
16
+ | | agent 开始跑:静止 → 运动 | agent 全部结束:运动 → 静止 |
17
+ | --- | --- | --- |
18
+ | **亚空间跃迁**<br>`subspace` | ![亚空间跃迁:常规宇宙里三颗恒星,镜头锁定入口、跃迁进亚空间隧道,左侧列出会话](docs/images/subspace-enter.gif) | ![亚空间跃迁:会话全部结束,脱离隧道,回到三星系统](docs/images/subspace-exit.gif) |
19
+ | **魔法书斋**<br>`magic-tower` | ![魔法书斋:塔顶书房里骑士在月光下读书,镜头扎进书页、穿过符文传送门,骑士沿塔里的书阶上行](docs/images/magic-tower-enter.gif) | ![魔法书斋:会话全部结束,一本书飞到镜头前打开,回到月光下的书房](docs/images/magic-tower-exit.gif) |
20
+ | **时钟**<br>`basic` | ![「时钟」主题 19:00:仿 macOS 锁屏,日期时间、电池、Wi-Fi,底部一行「使用触控 ID 或输入密码」](docs/images/basic-start-zh.jpg) | ![「时钟」主题 19:42:还是同一个锁屏,只有时间走了](docs/images/basic-finish-zh.jpg) |
16
21
 
17
22
  ## 和系统锁屏、系统屏保、动态壁纸有什么不同
18
23
 
@@ -45,7 +50,7 @@ dsh plugin --profile web add dsh-screensaver
45
50
  DeepSeek Harness 桌面版把 `web` 换成 `desktop`。装好后重启 dsh。第一次启动会下载 Electron 运行时(约 100 MB,只下载一次);
46
51
  如果装了 Xcode 命令行工具,还会在本机编译 Touch ID 小程序。
47
52
 
48
- 「时钟」和「亚空间跃迁」两个主题都随包自带,不用另装。
53
+ 「时钟」「亚空间跃迁」「魔法书斋」三个主题都随包自带,不用另装。
49
54
 
50
55
  想用 GitHub 上还没发布的最新代码,而不是 npm 上的发布版:
51
56
 
@@ -74,6 +79,7 @@ npx dsh-screensaver setup # 改配置:合盖不睡(顺手授
74
79
  | --- | --- |
75
80
  | `/screensaver` | 用默认主题开启 |
76
81
  | `/screensaver <主题>` | 用指定主题开启,例如 `/screensaver subspace` |
82
+ | `/screensaver <主题> <主题> …` | 每块屏幕一个主题,主屏第一,例如 `/screensaver magic-tower subspace` |
77
83
  | `/screensaver themes` | 查看已安装的主题 |
78
84
  | `/screensaver lid` | 查看合盖不睡的状态 |
79
85
  | `/screensaver lid authorize` | 授权合盖不睡:输入一次管理员密码,安装一条只允许 `pmset -a disablesleep 0/1` 的 sudoers 规则 |
@@ -88,6 +94,7 @@ npx dsh-screensaver setup # 改配置:合盖不睡(顺手授
88
94
  - id: dsh-screensaver
89
95
  config:
90
96
  theme: subspace # 默认主题
97
+ screens: [magic-tower, subspace] # 可选:每块屏幕不同的主题(见下面「多块屏幕」)
91
98
  idleMinutes: 10 # 空闲 10 分钟自动开启;0 表示不自动开启(默认)
92
99
  lidAwake: true # 开启屏保时顺便打开合盖不睡(默认开,写 false 关掉)
93
100
  shortcut: Control+Alt+Command+L # Electron 快捷键写法;填 '' 不注册快捷键
@@ -97,15 +104,22 @@ npx dsh-screensaver setup # 改配置:合盖不睡(顺手授
97
104
 
98
105
  | 命令 | 作用 |
99
106
  | --- | --- |
100
- | `dsh-screensaver setup` | 一问一答:合盖不睡(当场授权)、主题、空闲自动开启 |
107
+ | `dsh-screensaver setup` | 一问一答:合盖不睡(当场授权)、主题、每块屏幕的主题、空闲自动开启 |
101
108
  | `dsh-screensaver config` | 查看配置和配置文件位置 |
102
- | `dsh-screensaver config <项> <值>` | 改一项,例如 `config lidAwake off`、`config idleMinutes 10` |
109
+ | `dsh-screensaver config <项> <值>` | 改一项,例如 `config lidAwake off`、`config idleMinutes 10`、`config screens magic-tower,subspace` |
103
110
  | `dsh-screensaver config unset <项>` | 改回默认 |
104
111
  | `dsh-screensaver lid [status\|authorize\|revoke]` | 合盖不睡授权,同 `/screensaver lid` |
105
112
  | `dsh-screensaver themes` | 查看已安装的主题 |
106
113
 
107
114
  `DSH_SCREENSAVER_CONFIG='{"theme":"subspace"}'` 只对这一次生效,盖过配置文件。`--now` 交给已经在跑的屏保(比如 dsh 里那个)时,
108
- 如果这次写了 `lidAwake`(配置文件或环境变量里),会一起带过去;没写就按那个屏保自己的配置。
115
+ 如果这次写了 `lidAwake`、`screens`(配置文件或环境变量里),会一起带过去;没写就按那个屏保自己的配置。
116
+
117
+ ### 多块屏幕
118
+
119
+ 不写 `screens` 时所有屏幕用同一个主题。`screens` 是一串主题 id,一块屏幕一个:第一个给主屏(有菜单栏的那块),
120
+ 其余按从左到右给别的屏幕(左右一样再从上到下),屏幕比列表多时,多出来的用最后一个。
121
+ `[magic-tower, subspace]` 就是主屏魔法书斋、其余屏幕亚空间跃迁;`[magic-tower, subspace, basic]` 让第三块屏幕显示时钟。
122
+ 屏保开着时新插上的屏幕也按这个规则分。某一次明说了一个主题(`--now subspace`、`/screensaver subspace`),这一次所有屏幕都用它。
109
123
 
110
124
  ## 主题
111
125
 
@@ -113,11 +127,29 @@ npx dsh-screensaver setup # 改配置:合盖不睡(顺手授
113
127
  | --- | --- | --- | --- |
114
128
  | 时钟 | `basic` | 内置 | 否 |
115
129
  | 亚空间跃迁 | `subspace` | 内置 | 是 |
130
+ | 魔法书斋 | `magic-tower` | 内置 | 是 |
131
+
132
+ - **亚空间跃迁**:常规宇宙里三颗恒星绕转;agent 在跑时跃迁进亚空间隧道,在星云雷暴、浪涌龙卷、高斯粒子三种画风之间切换。
133
+ - **魔法书斋**:HD-2D 像素场景。塔顶书房里骑士在月光下读书;agent 在跑时镜头扎进书页、进塔,骑士沿书阶上行。左侧法卷列出会话,
134
+ 右上角状态栏(带今晚的月相)和底部的触控 ID 法阵也由它自己画,位置跟外壳一样。
116
135
 
117
- 更多主题陆续推出。每个主题就是一个文件夹:`index.html` 负责绘制(运行在沙盒 iframe 里),`saver.json` 写名称等信息。
136
+ 所有主题的布局一样:会话列表在左侧,日期时间在右上角,触控 ID 提示在底部正中;30 秒没人动就都淡掉,只剩画面。
137
+
138
+ 每个主题就是一个文件夹:`index.html` 负责绘制(运行在沙盒 iframe 里),`saver.json` 写名称等信息。
118
139
  自己做的主题放进 `~/.dsh/plugins-data/dsh-screensaver/themes/<id>/` 就能用,也可以发布成 npm 包,在 `package.json` 里写上
119
140
  `"dsh-screensaver": { "theme": "." }`。详见 [docs/themes.md](docs/themes.md)。
120
141
 
142
+ ### 做一个自己的主题
143
+
144
+ [`skills/dsh-screensaver-theme`](skills/dsh-screensaver-theme/SKILL.md) 是一个 agent skill,写的是每个主题都要守的规矩,不管画风:
145
+ 静止画面和运动画面以及中间的转场、会话列表、右上角状态栏和时间、触控 ID 反馈、30 秒自动隐藏、副屏和用电池时降帧、`#demo` 演示页、打包,
146
+ 还附了录 README 动图的脚本。画风完全由你定。
147
+
148
+ 把这个文件夹复制到 `~/.claude/skills/`(或项目里的 `.claude/skills/`)给 Claude Code 用,或者让别的 coding agent 读 `SKILL.md`,
149
+ 然后说出你的脑洞:「做一个 dsh-screensaver 主题,……」。`themes/` 里两个主题是可以照着看的完整实现。
150
+
151
+ 欢迎新主题、新脑洞,也欢迎一起改进这个 skill:主题放到 `themes/` 下开 PR,想法可以先开 issue 聊。skill 大家一起维护,碰到它没写到的规矩就补上。
152
+
121
153
  ## 能识别哪些 agent 会话
122
154
 
123
155
  只有声明了 `"sessions": true` 的主题才会收到会话信息,而且只在屏保开启时读取。每 2 秒读一次本机文件,不联网,不上传任何数据。
@@ -159,7 +191,8 @@ git clone https://github.com/realRoc/dsh-screensaver && cd dsh-screensaver
159
191
  npm install
160
192
  npm test # 运行测试(vitest)
161
193
  npm run now # 立即开启屏保试一下
162
- npm run build:themes # 修改 themes/subspace/src 后重新打包 index.html
194
+ npm run build:themes # 修改 themes/*/src 后重新打包 index.html
195
+ node skills/dsh-screensaver-theme/scripts/record-gif.mjs … # 录 README 动图,用法见脚本开头的注释
163
196
  DSH_SCREENSAVER_DEBUG=1 npm run now # 打印页面里的 console 输出
164
197
  ```
165
198
 
package/app/main.js CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // 1. dsh 插件的子进程(lib/index.js 起的,DSH_SCREENSAVER_CONTROL=stdin):
4
4
  // stdin 一行一条 JSON 指令,stdout 回 JSON(都带 "$" 字段,别的输出当日志),stdin 断了(dsh 退出)就收尾退出。
5
- // → { "$": "start", "theme": "subspace" } 开屏保(theme 可省)
5
+ // → { "$": "start", "theme": "subspace" } 开屏保(theme 可省;给了就所有屏幕都用它)
6
+ // → { "$": "start", "screens": ["magic-tower", "subspace"] } 这一次每块屏幕的主题(主屏第一,见 screens.js)
6
7
  // → { "$": "config", "config": { ... } } 改配置
7
8
  // → { "$": "themes", "id": 1 } 列主题 ← { "$": "reply", "id": 1, "result": [...] }
8
9
  // → { "$": "lid", "action": "status|authorize|revoke|on|off", "id": 2 }
@@ -28,8 +29,8 @@ function readConfig() {
28
29
  }
29
30
 
30
31
  // 同一时间只开一个:第二次 `dsh-screensaver --now` 交给已经在跑的那个去开,
31
- // 连同这次明说了的合盖不睡设置(比如桌宠开的、dsh 里配的是关,这一次也按桌宠的来);没说就按那个实例自己的配置
32
- if (!app.requestSingleInstanceLock({ now, theme: nowTheme, lidAwake: readConfig().lidAwake })) app.exit(0)
32
+ // 连同这次明说了的合盖不睡、每块屏幕的主题(比如桌宠开的、dsh 里配的是关,这一次也按桌宠的来);没说就按那个实例自己的配置
33
+ if (!app.requestSingleInstanceLock({ now, theme: nowTheme, lidAwake: readConfig().lidAwake, screens: readConfig().screens })) app.exit(0)
33
34
  registerScheme()
34
35
  app.dock?.hide() // 不进程序坞,不抢 Cmd+Tab
35
36
 
@@ -50,7 +51,7 @@ async function handle(msg) {
50
51
  try {
51
52
  switch (msg.$) {
52
53
  case 'start':
53
- await saver.start(msg.theme)
54
+ await saver.start(msg.theme, Array.isArray(msg.screens) ? { screens: msg.screens } : {})
54
55
  return reply(true)
55
56
  case 'config':
56
57
  saver.applyConfig(msg.config ?? {})
@@ -109,7 +110,7 @@ async function main() {
109
110
  },
110
111
  })
111
112
  app.on('second-instance', (_e, _argv, _cwd, data) => {
112
- if (data?.now) void saver.start(data.theme, { lidAwake: data.lidAwake })
113
+ if (data?.now) void saver.start(data.theme, { lidAwake: data.lidAwake, screens: Array.isArray(data.screens) ? data.screens : undefined })
113
114
  })
114
115
  app.on('window-all-closed', () => {}) // 屏保关了程序不退:等下一次快捷键 / 指令
115
116
  app.on('before-quit', (e) => {
package/app/saver.js CHANGED
@@ -15,6 +15,7 @@
15
15
  // - 主屏右上角跟系统菜单栏一样放电池、Wi-Fi、日期时间:`desk-unlock --status` 读(IOKit + CoreWLAN),每 20 秒一次。
16
16
  // - 屏保里放什么由主题决定(themes.js 找到的目录,沙盒 iframe 里跑)。
17
17
  // saver.json 写了 "sessions": true 的主题,屏保开着时才去读本机 agent 会话(agents.js),推给它显示。
18
+ // - 每块屏幕可以放不同的主题:配置 screens(主屏第一,其余从左到右;屏幕多出来的用最后一个),见 screens.js。
18
19
  //
19
20
  // 这不是安全边界:长按电源键之类的拦不住。它挡的是路过的人看屏幕、碰键盘。
20
21
  import { execFile, spawn } from 'node:child_process'
@@ -27,6 +28,7 @@ import { dataDir } from './dirs.js'
27
28
  import { ensureHelper } from './helper.js'
28
29
  import { LidAwake } from './lidawake.js'
29
30
  import { loadShell, mountTheme, preloadPath, themeUrl } from './paths.js'
31
+ import { assignThemes } from './screens.js'
30
32
  import { DEFAULT_THEME, listThemes } from './themes.js'
31
33
 
32
34
  export const DEFAULT_SHORTCUT = process.platform === 'darwin' ? 'Control+Alt+Command+L' : 'Control+Alt+Shift+L'
@@ -55,7 +57,7 @@ const SAY = {
55
57
 
56
58
  export class Screensaver {
57
59
  /**
58
- * @param {{ theme?: string, lidAwake?: boolean, idleMinutes?: number, shortcut?: string }} config
60
+ * @param {{ theme?: string, screens?: string[], lidAwake?: boolean, idleMinutes?: number, shortcut?: string }} config
59
61
  * @param {{ say?: (text: string) => void, onState?: (active: boolean) => void }} hooks
60
62
  * say:给人看的一句话(dsh 里打到日志);onState:屏保开了 / 关了
61
63
  */
@@ -64,7 +66,8 @@ export class Screensaver {
64
66
  this.hooks = hooks
65
67
  this.wins = new Map() // display.id → 窗口
66
68
  this.kioskWin = null
67
- this.current = null
69
+ /** 这次屏保的安排:明说的主题、每块屏幕的列表(屏幕插拔时按它重排) */
70
+ this.plan = null
68
71
  this.blocker = null
69
72
  this.authing = false
70
73
  this.agents = new AgentWatcher()
@@ -81,7 +84,7 @@ export class Screensaver {
81
84
  this.lidManual = false
82
85
  this.helper = null
83
86
  this.shortcut = null
84
- this.onDisplayAdded = (_e, d) => this.cover(d)
87
+ this.onDisplayAdded = (_e, d) => this.cover(d, d.id === screen.getPrimaryDisplay().id)
85
88
  this.onDisplayRemoved = (_e, d) => {
86
89
  this.wins.get(d.id)?.destroy()
87
90
  this.wins.delete(d.id)
@@ -165,15 +168,34 @@ export class Screensaver {
165
168
  for (const w of win ? [win] : this.wins.values()) if (!w.isDestroyed()) w.webContents.send('saver:sessions', payload)
166
169
  }
167
170
 
171
+ /** 这次屏保每块屏幕的主题:Map(display.id → 主题);明说了主题就所有屏幕都用它,否则按 screens(screens.js) */
172
+ screenThemes(plan = this.plan) {
173
+ const ids = assignThemes(screen.getAllDisplays(), screen.getPrimaryDisplay().id, {
174
+ theme: plan?.theme,
175
+ screens: plan?.theme ? undefined : plan?.screens,
176
+ })
177
+ const out = new Map()
178
+ for (const [id, themeId] of ids) {
179
+ const theme = this.theme(themeId)
180
+ if (theme) out.set(id, theme)
181
+ }
182
+ return out
183
+ }
184
+
168
185
  /**
169
- * 开屏保。opts.lidAwake:这一次要不要合盖不睡(`--now` 交给已经在跑的这个时带过来的),不给就看配置,配置没写算开
186
+ * 开屏保。themeId:这一次所有屏幕都用这个主题(不给就按配置的 screens / theme)。
187
+ * opts.lidAwake:这一次要不要合盖不睡(`--now` 交给已经在跑的这个时带过来的),不给就看配置,配置没写算开。
188
+ * opts.screens:这一次每块屏幕的主题(同上,交给已经在跑的这个时带过来的),不给就看配置。
170
189
  */
171
190
  async start(themeId, opts = {}) {
172
191
  if (this.active) return
173
- const theme = this.theme(themeId)
174
- if (!theme) return this.say('[dsh-screensaver] no theme found')
175
- mountTheme(theme.id, theme.dir)
176
- this.current = theme
192
+ this.plan = { theme: themeId, screens: opts.screens ?? this.config.screens }
193
+ const themes = [...this.screenThemes().values()]
194
+ if (!themes.length) {
195
+ this.plan = null
196
+ return this.say('[dsh-screensaver] no theme found')
197
+ }
198
+ for (const t of themes) mountTheme(t.id, t.dir)
177
199
  if (!this.canAuthenticate()) this.say(SAY.noAuth[saverLang()])
178
200
  if ((opts.lidAwake ?? this.config.lidAwake) !== false && !this.lid.active && this.lid.supported) {
179
201
  try {
@@ -189,7 +211,7 @@ export class Screensaver {
189
211
  }
190
212
  }
191
213
  if (this.blocker === null) this.blocker = powerSaveBlocker.start('prevent-display-sleep')
192
- this.wantsSessions = !!theme.sessions
214
+ this.wantsSessions = themes.some((t) => t.sessions)
193
215
  if (this.wantsSessions) {
194
216
  this.agents.lang = saverLang()
195
217
  this.agents.start((list) => this.sendSessions(list))
@@ -204,7 +226,19 @@ export class Screensaver {
204
226
  }
205
227
 
206
228
  cover(d, primary = false) {
207
- if (this.wins.has(d.id) || !this.current) return
229
+ if (this.wins.has(d.id) || !this.plan) return
230
+ // 插上的屏幕会改变排序,所以每次按现在的屏幕重排一遍;只给还没盖的这块用,已经开着的不动
231
+ const theme = this.screenThemes().get(d.id) ?? this.theme(this.plan.theme)
232
+ if (!theme) return
233
+ mountTheme(theme.id, theme.dir)
234
+ if (process.env.DSH_SCREENSAVER_DEBUG) this.say(`[debug] screen ${d.id}${primary ? ' (main)' : ''} → ${theme.id}`)
235
+ if (theme.sessions && !this.wantsSessions) {
236
+ this.wantsSessions = true
237
+ this.agents.lang = saverLang()
238
+ this.agents.start((list) => this.sendSessions(list))
239
+ powerMonitor.on('on-battery', this.onPowerChange)
240
+ powerMonitor.on('on-ac', this.onPowerChange)
241
+ }
208
242
  const b = d.bounds
209
243
  const win = new BrowserWindow({
210
244
  ...b,
@@ -226,7 +260,7 @@ export class Screensaver {
226
260
  win.setAlwaysOnTop(true, 'screen-saver')
227
261
  if (process.platform === 'darwin') win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true, skipTransformProcessType: true })
228
262
  this.wins.set(d.id, win)
229
- void loadShell(win, { theme: themeUrl(this.current.id), primary: primary ? '1' : '', lang: saverLang() }).catch((e) =>
263
+ void loadShell(win, { theme: themeUrl(theme.id), primary: primary ? '1' : '', lang: saverLang(), hud: theme.hud ? '1' : '' }).catch((e) =>
230
264
  this.say(`[dsh-screensaver] screen failed to load: ${e?.message ?? e}`),
231
265
  )
232
266
  win.webContents.on('render-process-gone', (_e, d) => this.say(`[dsh-screensaver] screen renderer gone: ${d.reason}`))
@@ -320,12 +354,14 @@ export class Screensaver {
320
354
  const child = spawn(this.helper, ['--listen', '--lang', lang, REASON[lang]], { stdio: ['ignore', 'pipe', 'pipe'] })
321
355
  this.listener = child
322
356
  let out = ''
323
- // 摸到传感器(认没认出来都算)打一行 touch:让主屏把 30 秒后藏起来的提示、状态栏露出来。
357
+ // 摸到传感器打一行 touch match(认出来了)/ touch miss(没认出来):让主屏把 30 秒后藏起来的提示、状态栏露出来,
358
+ // 自己画提示的主题("hud": true)还拿它做反馈。老版本只打 touch。
324
359
  // 输出一块块来,一行可能被切成两块,所以先拼成整行再认
325
360
  const readLine = lineReader((line) => {
326
- if (line !== 'touch') return
361
+ const m = /^touch(?: (match|miss))?$/.exec(line)
362
+ if (!m) return
327
363
  const win = this.kioskWin
328
- if (win && !win.isDestroyed()) win.webContents.send('saver:touch')
364
+ if (win && !win.isDestroyed()) win.webContents.send('saver:touch', m[1] ?? '')
329
365
  })
330
366
  child.stdout?.on('data', (b) => {
331
367
  out += b
@@ -375,6 +411,7 @@ export class Screensaver {
375
411
  powerMonitor.off('on-battery', this.onPowerChange)
376
412
  powerMonitor.off('on-ac', this.onPowerChange)
377
413
  this.wantsSessions = false
414
+ this.plan = null
378
415
  if (this.kioskWin && !this.kioskWin.isDestroyed()) {
379
416
  this.kioskWin.setKiosk(false)
380
417
  if (process.platform === 'darwin') this.kioskWin.setSimpleFullScreen(false)
package/app/screens.js ADDED
@@ -0,0 +1,36 @@
1
+ // 每块屏幕放哪个主题。不碰 Electron,好测。
2
+ //
3
+ // 配置 screens 是一串主题 id,按屏幕顺序排:第一个给主屏,后面的给其余屏幕(从左到右,左右一样再从上到下)。
4
+ // 屏幕比列表多时,多出来的用最后一个:["magic-tower", "subspace"] 就是「主屏魔法书斋,别的屏都是亚空间」。
5
+ // screens 空着(默认)所有屏幕用同一个主题(theme)。
6
+ // 开屏保时明说了一个主题(`--now subspace`、/screensaver subspace),这一次所有屏幕都用它,不看 screens。
7
+
8
+ /**
9
+ * 屏幕排顺序:主屏第一,其余从左到右,左右一样再从上到下。
10
+ * @param {{ id: number, bounds: { x: number, y: number } }[]} displays
11
+ * @param {number} primaryId
12
+ */
13
+ export function orderDisplays(displays, primaryId) {
14
+ const rest = displays.filter((d) => d.id !== primaryId).sort((a, b) => a.bounds.x - b.bounds.x || a.bounds.y - b.bounds.y)
15
+ const primary = displays.find((d) => d.id === primaryId)
16
+ return primary ? [primary, ...rest] : rest
17
+ }
18
+
19
+ /** 第 index 块屏幕(0 = 主屏)用哪个主题 id;screens 空着就是 fallback */
20
+ export function themeForScreen(index, screens, fallback) {
21
+ const list = Array.isArray(screens) ? screens.filter((s) => typeof s === 'string' && s) : []
22
+ if (!list.length) return fallback
23
+ return list[Math.min(index, list.length - 1)]
24
+ }
25
+
26
+ /**
27
+ * 每块屏幕的主题 id:Map(display.id → 主题 id)。
28
+ * @param {{ id: number, bounds: { x: number, y: number } }[]} displays
29
+ * @param {number} primaryId
30
+ * @param {{ theme?: string, screens?: string[] }} plan theme:明说的 / 配置的主题;screens:每块屏幕的
31
+ */
32
+ export function assignThemes(displays, primaryId, { theme, screens } = {}) {
33
+ const out = new Map()
34
+ orderDisplays(displays, primaryId).forEach((d, i) => out.set(d.id, themeForScreen(i, screens, theme)))
35
+ return out
36
+ }
@@ -20,6 +20,8 @@
20
20
  /* 纯享:进屏保 30 秒没人动,底部那行字、右上角状态栏都淡掉(主题那边同时藏会话播报),只剩画面 */
21
21
  #hint, #status { transition: opacity 1.2s ease; }
22
22
  body.pure #hint, body.pure #status { opacity: 0; }
23
+ /* 主题自己画状态栏和提示(saver.json 的 "hud": true):外壳的藏起来,但照样算好内容转给主题 */
24
+ body.theme-hud #hint, body.theme-hud #status { visibility: hidden; }
23
25
  /* 右上角:电池、Wi-Fi、日期时间,位置、大小、写法照着系统菜单栏(「11月15日 周日 下午6:10」) */
24
26
  #status {
25
27
  position: fixed; top: 6px; right: 14px; height: 24px; display: flex; align-items: center; gap: 13px;