npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stopsleep

v0.1.4

Published

CLI:随机移动鼠标以阻止电脑睡眠(Windows/macOS)

Readme

stopsleep

阻止电脑进入睡眠的命令行工具。通过在后台以随机间隔轻微移动鼠标,模拟有人在使用电脑。

特性

  • 随机间隔(默认 10–50 秒)轻微移动鼠标,直到手动停止
  • 支持 Windows 与 macOS,无需安装 Python 或其他额外环境
  • 支持中英文输出:--lang en|cn(也可用 --en / --cn
  • 输出运行时间、下次间隔、鼠标移动坐标,并模拟“开发任务”日志
  • 支持弹窗提醒:固定或随机间隔弹窗提示休息与喝水(--popup

环境要求

  • Node.js >= 16
  • Windows:无需额外依赖(通过 PowerShell 控制鼠标)
  • macOS:系统内置 osascript(JXA)与 CoreGraphics

安装 stopsleep 模块

  • 全局安装:npm i -g stopsleep
  • 运行:stopsleep [参数](示例:stopsleep --lang cn --delay 10,50
  • 停止:Ctrl + C
  • 卸载:npm uninstall -g stopsleep

命令行参数

  • --lang en|cn:设置语言(默认 cn)。也支持快捷参数 --en--cn
  • --delay a,b:以逗号分隔(支持中文逗号),定义随机间隔范围(秒)。如 --delay 10,50
  • --min <n>--max <n>:当未提供 --delay 时,使用这两个参数定义范围。默认 min=10max=50
  • --iterations <n>:执行次数上限(用于快速验证)。不传表示一直运行,直到手动停止
  • --popup [n|a,b]:开启弹窗提醒。n 为固定间隔秒数;a,b 为随机范围(秒)。不带值默认每 1800 秒弹窗。Windows 使用系统弹窗(自动 5 秒关闭),macOS 使用系统通知。
  • --popupNote "<文本>":自定义弹窗中“总运行时间”后的提示文案。例如 --popupNote "请起身活动并喝水";英文示例:--popupNote "Remember to stretch"

优先级:当提供 --delay 时会覆盖 --min--max

使用示例

  • 默认中文:
    • stopsleep
  • 指定中文与范围:
    • stopsleep --lang cn --delay 10,50
  • 指定英文:
    • stopsleep --lang en --min 15 --max 30
  • 快速验证(运行两次后退出):
    • stopsleep --lang en --delay 1,1 --iterations 2
  • 开启弹窗(默认 1800 秒):
    • stopsleep --popup
  • 开启弹窗(固定 300 秒):
    • stopsleep --popup 300
  • 开启弹窗(随机 300–600 秒):
    • stopsleep --popup 300,600
  • 自定义弹窗提示文案:
    • stopsleep --popup 600 --popupNote "请起身活动并喝水"

输出示例

中文:

阻止电脑睡眠:随机轻微移动鼠标
间隔范围:10s - 50s
按 Ctrl+C 手动停止

[00:00:00] 下一次间隔 12s | 鼠标: (100,200) -> (103,205) | 编译模块 成功

英文:

Prevent sleep: random slight mouse move
Interval range: 10s - 50s
Press Ctrl+C to stop

[00:00:00] Next interval 12s | Mouse: (100,200) -> (103,205) | Run unit tests Passed

技术实现

  • Windows:使用 PowerShell 调用 System.Windows.Forms.Cursor 获取与设置鼠标位置
  • macOS:使用 osascript -l JavaScript(JXA)调用 CoreGraphics,通过 CGEventCreateMouseEventCGEventPost 发送鼠标移动事件
  • 弹窗提醒:
    • Windows:通过 PowerShell 调用 WScript.Shell.Popup 显示系统弹窗(自动 5 秒关闭)
    • macOS:通过 osascript 执行 display notification 显示系统通知

对应代码位置:

  • 参数解析与默认值:bin/stopsleep.jsparseArgsmain
  • 延迟范围解析(支持 --delay a,b):bin/stopsleep.jsmain 的范围计算逻辑
  • 平台鼠标移动:
    • Windows:bin/stopsleep.js 中调用 PowerShell 的片段
    • macOS:bin/stopsleep.js 中调用 osascript 的片段
  • 弹窗提醒:
    • 调度循环:bin/stopsleep.jsschedulePopupReminders
    • 平台弹窗显示:bin/stopsleep.jsshowPopup

注意事项

  • 鼠标移动幅度很小(最多 ±8px/±6px),尽量不影响正常操作
  • 在 macOS 上,若发现鼠标无法被程序控制,可能需要为终端/命令行工具授予“辅助功能”权限(系统偏好设置 → 隐私与安全性 → 辅助功能)
  • 程序将持续运行直到手动停止(Ctrl+C

许可协议

MIT