Monitor/README.md
2026-05-05 21:30:01 +08:00

73 lines
2.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Monitor
> macOS 原生系统监控悬浮窗 —— 实时 CPU/GPU/内存/Swap + Top进程半透明可拖动一切可定制。
## 截图
点击菜单栏 <img src="https://img.shields.io/badge/⏲-Monitor-blue" height="18"> 图标呼出悬浮窗:
```
┌──────────────────────┐
│ ⏲ Monitor 21:30:00 ✕│
│──────────────────────│
│ CPU ████████░░ 42% │
│ 10 核心 · Apple M2 Pro│
│ │
│ 内存 ███░░░░░░░ 35% │
│ 5.6 / 16 GB │
│ │
│ CPU 消耗 Top │
│ WindowServer 12.3% │
│ Code 8.1% │
└──────────────────────┘
```
## 功能
- **CPU / GPU / 内存 / Swap** 实时占用率
- **Top 进程** 按 CPU 和内存消耗排列
- **5 种计量器样式**:圆环、条状、纯文本、扇形、紧凑横条
- **灵活布局**:每个模块独立指定行号 + 左/右/全宽列位
- **半透明悬浮窗**:毛玻璃 HUD 风格,任意拖动
- **菜单栏图标**:左键切换显隐,右键菜单(设置、退出)
- **独立设置窗口**:显示内容、样式、行号列位、宽高、字体、透明度、刷新率全部可调
## 安装
### 方式一DMG
下载 `Monitor.dmg`,将 `FloatingMonitor` 拖入 Applications。
### 方式二:源码运行
```bash
git clone git@git.cyjai.com:JOJO/Monitor.git
cd Monitor
swift run
```
## 要求
- macOS 14 (Sonoma) 或更高
- Xcode 16+ 或 Swift 6.2 工具链
## 使用
1. 启动后菜单栏出现仪表盘图标
2. **左键点击**图标 → 切换悬浮窗显隐
3. **右键点击**图标 → 展开菜单(显示设置 / 退出)
4. 悬浮窗可**任意拖动**,设置中可调宽高
## 技术
| 层面 | 实现 |
|------|------|
| CPU 采样 | `host_statistics` 双采样差值 |
| GPU 占用 | IOKit `IOAccelerator``PerformanceStatistics` |
| 内存/Swap | `vm_statistics64` / `sysctl vm.swapusage` |
| 进程列表 | `ps -eo pid,%cpu,rss,comm` |
| UI | SwiftUI + AppKit `NSHostingView` |
| 毛玻璃 | `NSVisualEffectView` `.hudWindow` + `.behindWindow` |
## 许可
MIT