I built a free Mac app that hides Desktop icons by flipping one bit
说明与用途
Bare 通过切换 UF_HIDDEN 标志,仅隐藏 macOS 桌面上的屏幕截图,并提供全局热键快速切换可见性。
问题
Hide Desktop icons on macOS without paying for paid apps and without moving files.
结果
Bare hides only screenshots on the Desktop by flipping the UF_HIDDEN flag, allowing quick toggle via a global hotkey, and automatically hides new screenshots as they appear.
工作流
- 1. Scan ~/Desktop for items
- 2. Classify items by type (aliases, apps, folders, screenshots, others)
- 3. For each item, if it matches hide criteria, set UF_HIDDEN flag via lstat/lchflags
- 4. Track hidden items by name to allow selective unhide
- 5. Use a DispatchSource to watch for new screenshots and hide them automatically
- 6. Provide a global hotkey (⌃⌥⌘H) via RegisterEventHotKey to toggle visibility
- 7. For disk icons, toggle Finder preference ShowHardDrivesOnDesktop and relaunch Finder
证据
I wanted to hide the icons on my Mac Desktop. That was the whole requirement.
Bare: a small menu bar app with one job. Click the eye, the Desktop is clean. Click again, everything is back.
macOS already has a "hidden" flag on the filesystem: UF_HIDDEN, the same one chflags hidden sets.
If you'd already hidden some files yourself, a simple "unhide everything" would reveal them. So Bare keeps a set of the names it hid.
The edge case I haven't solved: Tracking by name means that if you rename a file while it's hidden, it leaves the set, and "Show" won't bring it back.
A DispatchSource file-system object watches ~/Desktop. Saving a file can fire several events, so the rescan is debounced by 0.4 seconds.
Most global-hotkey code asks for Accessibility access. Carbon's RegisterEventHotKey doesn't need it, and it's still the simplest way to do one global shortcut on macOS.
- 记录日期: 2026-10-17T03:56:00.221Z