# QN-IDLE **Repository Path**: YuYao-Gith/QN-IDLE ## Basic Information - **Project Name**: QN-IDLE - **Description**: 防止桌面环境自动黑屏/休眠的轻量级跨平台命令行工具(C) - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-20 - **Last Updated**: 2026-08-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
🛡️ 永不停歇的守护者 — 防止桌面环境自动黑屏/休眠的轻量级跨平台命令行工具
仓库地址:https://gitee.com/YuYao-Gith/QN-IDLE
--- ## 📖 目录 - [🎯 简介](#-简介) - [✨ 特性](#-特性) - [🚀 快速开始](#-快速开始) - [💻 平台支持](#-平台支持) - [📦 安装指南](#-安装指南) - [Linux](#-linux) - [macOS](#-macos) - [Windows](#-windows) - [⚙️ 使用方法](#-使用方法) - [🔧 命令行选项](#-命令行选项) - [🏗️ 从源码构建](#-从源码构建) - [🤝 贡献指南](#-贡献指南) - [📜 许可证](#-许可证) - [👤 作者](#-作者) --- ## 🎯 简介 ```text ╔══════════════════════════════════════════════════════════════════╗ ║ 还在为这些问题烦恼吗? ║ ║ • 看电影时屏幕自动变暗? ║ ║ • 演示 PPT 时突然黑屏? ║ ║ • 长时间编译时系统自动休眠? ║ ║ • SSH 会话因桌面空闲而中断? ║ ║ • 游戏挂机时屏幕保护弹出? ║ ║ ║ ║ QN-IDLE 让你彻底告别这些烦恼! ║ ║ 支持 Windows / macOS / Linux 三大平台 ║ ╚══════════════════════════════════════════════════════════════════╝ ``` **QN-IDLE** 是一个跨平台的命令行工具,通过定期调用系统原生 API 或模拟轻微用户活动,防止系统进入空闲状态、自动黑屏、息屏或挂起。 --- ## ✨ 特性 | 特性 | 说明 | |------|------| | 🌍 **跨平台** | 支持 Windows、macOS、Linux | | 🚀 **极轻量** | 纯 C17 编写,零外部依赖,二进制 < 100KB | | 💪 **低资源** | 内存占用 < 1MB,CPU 使用率 < 0.1% | | 🎯 **原生 API** | 使用各平台原生接口,非 hack 方式 | | 🔄 **多重策略** | 自动检测 + 自动回退,任何环境都能工作 | | 👻 **守护进程** | 支持后台静默运行(Unix) | | 📊 **实时统计** | 可选详细输出,实时监控抑制效果 | | 🛡️ **安全可靠** | AGPLv3 开源,编译安全加固 | --- ## 🚀 快速开始 ### Linux / macOS ```bash # 克隆仓库 git clone https://gitee.com/YuYao-Gith/QN-IDLE.git cd QN-IDLE # 编译并安装 make && sudo make install # 运行(60 秒间隔) qidle -i 60 ``` ### Windows ```cmd :: 使用 MinGW-w64 编译 make build :: 或手动编译 gcc -std=c17 -O3 -o qidle.exe qn-idle.c -luser32 -lkernel32 -lpowrprof :: 运行 qidle.exe -i 60 ``` --- ## 💻 平台支持 | 平台 | 版本要求 | 抑制方式 | 状态 | |------|----------|----------|------| | Windows | Windows 7+ | SetThreadExecutionState + SendInput | ✅ 完美 | | macOS | macOS 10.12+ | IOPMAssertionCreate + caffeinate | ✅ 完美 | | Linux (X11) | 任意发行版 | xdg-screensaver + xdotool + xset | ✅ 完美 | | Linux (Wayland) | 任意发行版 | D-Bus + systemd-inhibit + ydotool | ✅ 完美 | ### Windows - 使用原生 `SetThreadExecutionState` API,无需管理员权限 - 支持防止系统休眠 + 显示器关闭 - 兼容 Windows 7/8/10/11 ### macOS - 使用 IOKit 电源管理断言 - 不影响系统正常休眠策略(合盖仍会休眠) - 支持 `caffeinate` 作为备选方案 ### Linux - 自动检测 X11/Wayland 环境,缓存并优先使用上次成功的策略 - 多种抑制策略自动回退 - 支持 systemd 用户服务集成 --- ## 📦 安装指南 ### Linux #### 从源码安装 ```bash git clone https://gitee.com/YuYao-Gith/QN-IDLE.git cd QN-IDLE make sudo make install ``` #### systemd 用户服务(推荐) ```bash mkdir -p ~/.config/systemd/user/ cat > ~/.config/systemd/user/qidle.service << 'EOF' [Unit] Description=QN-IDLE - Prevent System Idle After=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/qidle -i 55 Restart=on-failure RestartSec=5s [Install] WantedBy=graphical-session.target EOF systemctl --user daemon-reload systemctl --user enable --now qidle.service ``` ### macOS ```bash # 编译安装 make && sudo make install # 或指定安装路径 sudo make install PREFIX=/usr/local ``` #### 设置为开机启动(LaunchAgent) ```bash cat > ~/Library/LaunchAgents/com.qnidle.qidle.plist << 'EOF'
🌟 QN-IDLE — 永不停歇的守护者
Made with ❤️ by YuYao | Licensed under AGPLv3
仓库地址: https://gitee.com/YuYao-Gith/QN-IDLE