dsh-mchose-battery
简体中文 | English
A DSH (DeepSeek Harness) client plugin that shows the real-time battery level and connection mode (2.4G / USB) of an Mchose (迈从) wireless mouse in the sidebar, just above the settings button.
<table> <tr> <td align="center"> <img src="./image/screenshot-1.png" alt="screenshot 1" width="360" /><br/> <em>2.4G 模式效果</em> </td> <td align="center"> <img src="./image/screenshot-2.png" alt="screenshot 2" width="360" /><br/> <em>USB 接线模式效果</em> </td> </tr> </table>
It talks to the mouse directly from the browser via WebHID — no companion app, no driver, no daemon. It refreshes every 5 seconds, and automatically follows the mouse as it switches between wired USB and the 2.4G receiver.
> Requires a DSH Web GUI (http://127.0.0.1:3080), profile web.
Features
- 🪫 Real-time battery percentage (updates every 5s)
- 🔌 Connection mode: 2.4G / USB
- ⚡ Charging indicator
- 🎯 Sidebar widget injected right above the settings button (no background bar, gray icon + text)
- 🔄 Auto-detects wired ↔ wireless switching (5s polling + disconnect events)
How it works
The plugin reads the device's HID config interface (usagePage 0xFF01, VID 0x3837):
- Sends a profile-reload command on report
0x11 - The mouse pushes an E2 status report on input report
0x13 - The report is XOR-decoded into battery % / charging / device name
- Wired USB = PID
0x4018, 2.4G receiver = PID0x100A
Prerequisites
- A DSH installation with the
webprofile (Web GUI) - A browser with WebHID support: Chrome / Edge (desktop). Firefox and Safari do not support WebHID.
- An authorized mouse on first use: the browser will show the WebHID device-picker prompt — you must select the Mchose mouse and click Connect.
---
Installation
This package is a profile bundle (it declares dsh.bundle.patch), so it installs with the built-in DSH plugin command — no manual patch editing required. The bundle patch auto-registers the plugin as a host entry, which in turn makes DSH serve its WebHID client bundle to the browser.
Option A — via dsh plugin (recommended)
# from the registry where dsh-mchose-battery is published
dsh plugin --profile web add dsh-mchose-batteryThat's it. dsh plugin add runs pnpm add, detects the dsh.bundle declaration, and adds the package to the profile's bundle layer. Restart DSH and hard-refresh (Ctrl+Shift+R).
> If testing from a local checkout instead of a registry, a path spec works too: > dsh plugin --profile web add ./publish/dsh-mchose-battery
Option B — manual copy
For machines where dsh plugin/pnpm isn't convenient:
# put the whole folder where DSH can resolve it
git clone <your-repo> "$USERPROFILE\.dsh\node_modules\dsh-mchose-battery"and register a row in ~/.dsh/profiles/web/cordis.patch.yml:
- insert:
- id: mchose-battery
name: dsh-mchose-batteryThen restart DSH and hard-refresh the Web GUI (Ctrl+Shift+R). Open the console and you should see:
[mchose] loaded v4 (polling, no auto-flip)> ⚠️ Because DSH caches the client bundle revision at startup, you generally need to restart DSH (not just refresh) after installing/upgrading.
Full step-by-step instructions for colleagues: [INSTALL.md](INSTALL.md).
---
WebHID authorization (first run)
The first time (and after the browser "forget"s the device), DSH will show the WebHID device picker. Make sure:
1. The mouse is connected (wired or via 2.4G receiver). 2. Select the Mchose device from the list. 3. Click Connect.
The sidebar widget will then show e.g. 78% · 2.4G or USB · 100% · ⚡.
Troubleshooting
| Symptom | What to check |
|---|---|
| Sidebar shows "连接迈从鼠标" forever | WebHID picker not approved — click the widget / allow the device |
| "WebHID 不可用" | Not Chrome/Edge, or WebHID blocked |
Battery stuck at -- | Device not on the expected interface; check console for raw= hex |
| Stale mode after unplug | Should self-correct within ~5s (polling); if not, restart DSH |
Developing
The plugin is a plain npm package:
lib/index.js— host half (no-op)lib/client.js— browser client (WebHID), served by DSH's client-bundle mechanismpackage.json—dsh.clientmetadata (platform: "web",immediately: true)
node --check lib/client.js # syntax checkLicense
MIT