Saltar al contenido principal
Y

dsh-power-off

yiguln/dsh-power-off

A power button in the DSH composer toolbar: arm it and DSH shuts down the Windows PC once every session in the batch goes idle, with a cancellable countdown. It only fires after it actually saw a task run, a new task during the countdown cancels the shutdown, and with the default onlyOnSuccess no shutdown happens when any session in the batch errored. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Instalar

dsh plugin --profile web add github:yiguln/dsh-power-off

README

dsh-power-off

在 DSH 会话输入栏工具栏「AI 控制电脑」右侧新增一个电源图标按钮:激活后持续监听当前会话的任务进度,任务全部完成时自动关闭电脑,带倒计时与一键取消。

安装

从插件市场安装(推荐):DSH → 插件 → 发现,搜索 dsh-power-off,点安装。

命令行从 GitHub 安装:

dsh plugin add github:YIGULN/dsh-power-off

本地目录安装:

plugin_manager install_bundle  target=<本包目录的绝对路径>

安装后对所有会话生效,重启 DSH 后仍在。

用法

  1. 点电源按钮 → 图标点亮为绿色(已激活)。
  2. 插件持续监听当前会话的任务进度;任务全部完成(所有会话回到空闲)后,开始倒计时并执行 shutdown /s /t <sec>。
  3. 倒计时内或任务完成前再次点击 → 取消自动关机,图标恢复为未激活,关机绝不触发。

状态

状态视觉含义
未激活低亮、低饱和默认;点一下激活
已激活绿色 + 柔和光晕监听任务,完成后关机
关机执行中绿色脉冲倒计时中;悬浮显示剩余秒数,点一下取消
已取消短暂琥珀色闪烁已撤销,回到未激活

安全设计

  • 仅在「已激活 且 确有任务跑过 且 全部会话空闲 且(无错误或允许出错时关机)」时才关机;激活时没有任务在跑绝不会立即关机。
  • 倒计时中若又有新任务开始,自动撤消系统关机(保持激活,等下次完成)。
  • 取消时执行 shutdown /a 撤销系统定时器。
  • 激活状态持久化到 $DSH_HOME/dsh-power-off.json,切换/重载会话、重启 DSH 后保持一致。
  • 变更接口(激活/取消)仅接受同源(loopback)请求。
  • 任何异常路径(无任务、任务出错、被中断)都不会误触发关机。

配置

键范围默认说明
countdownSec10–60060倒计时秒数
marginSec0–605倒计时之外额外给系统的余量秒数
onlyOnSuccessbooltrue仅在本批次无会话出错时才关机

仅支持 Windows(调用 shutdown.exe);其他平台为惰性,不执行关机。

结构

  • index.js — host 半:状态机 + 事件监听 + shutdown 执行 + HTTP 路由 + 状态持久化
  • client.js — client 半:conversation.input.left slot 注入电源按钮,轮询 host 状态
  • cordis.patch.yml — bundle 补丁(向 profile 插入插件行)
  • locale/{en,zh}.json — 插件详情页元数据
  • docs/DETAIL.md、docs/DETAIL.zh.md — 插件市场详情文档
  • icon.svg — 插件图标

Plugins relacionados