Bare hides Mac Desktop icons by setting the filesystem's UF_HIDDEN flag on selected items. It saves the names of the items it changes, then removes that flag when you show them again. Files keep their contents and locations. Renaming a hidden file can leave it outside that restoration record.
I built Bare. This walkthrough follows version 1.0.0, commit 144f7c4. I checked its filesystem behavior on macOS 27.0.1, build 26A434, on Apple silicon, by compiling the unchanged hiding, classification, and settings code into an isolated runner. A temporary directory stood in for the Desktop. I did not test other macOS releases.
For setup steps, use how to hide Desktop icons on Mac.
Change the hidden bit and preserve the other flags
DesktopHider.swift reads the existing flags, changes the hidden bit, and writes the value back:
var st = stat()
guard lstat(path, &st) == 0 else { return false }
var flags = st.st_flags
if hidden {
flags |= UInt32(UF_HIDDEN)
} else {
flags &= ~UInt32(UF_HIDDEN)
}
return lchflags(path, flags) == 0
The bitwise operations preserve unrelated flags. In the isolated check, a file started with UF_NODUMP set. Both hiding and showing it preserved that flag, and reading its contents afterward returned the same bytes.
Using lstat and lchflags changes a symbolic link's flags without following it to the target. In the check, the link gained the hidden flag while its target outside the fixture Desktop stayed unchanged.
Finder can reveal these files when its show-hidden-files mode is enabled. The hidden flag does not restrict access to a document or encrypt it.
Scan Desktop items and classify them
Bare asks FileManager for the user's Desktop directory and enumerates its immediate children. It does not recursively hide files inside every Desktop folder. Names beginning with a period are skipped.
Each item becomes a record containing its URL, name, category, and current hidden state. Classifier.swift checks aliases and symbolic links, applications, folders, screen captures, and then other content types.
Screen captures receive an extra check before the general image and media categories. Bare looks for the com.apple.metadata:kMDItemIsScreenCapture extended attribute, then falls back to prefixes such as Screenshot, Screen Shot, and Screen Recording.
A renamed capture without the metadata may be classified as an ordinary image, while an unrelated file using a recognized prefix can be classified as a capture. The classifier checks for the attribute's presence; it does not decode its value. These rules determine which files the screenshots-only preset hides.
Keep a record of the items Bare changed
The restoration logic compares each scanned item's name with trackedNames, a set persisted in Settings.swift:
let ours = tracked.contains(item.name)
if item.isHidden && !ours { continue }
An already-hidden item outside that set is left alone. If a selected item is visible, Bare sets its hidden flag and adds its name to the set after the operation succeeds. When showing items, Bare clears the flag on tracked items and removes their names from the set.
| Item encountered during a scan | Result |
|---|---|
| Visible item in a selected category | Hide it and record its name. |
| Hidden item whose name Bare tracks | Keep it hidden or restore it according to the current mode. |
| Hidden item whose name Bare does not track | Leave it alone. |
| Tracked name absent after a successful scan | Remove the stale name from the record. |
If reading the directory fails, Bare preserves the tracking set instead of treating an empty scan as proof that the files disappeared. The isolated runner checked that behavior with an unavailable directory.
Filename tracking has a rename limitation
Version 1.0.0 tracks names rather than durable file identities. In the isolated check, Bare hid Screenshot demo.png, the runner renamed it to Screenshot renamed.png, and Bare's Show operation left the renamed file hidden. Its new name was outside the tracking set, so the rule for previously hidden files applied.
The same behavior can affect a hidden file moved out of the Desktop. Once it is outside the directory Bare scans, the app cannot restore it there. Showing items before renaming or moving them avoids that situation. The restoration guide also explains how to clear the hidden flag on one known file.
A different file can later occupy the same name. Tracking filesystem identity as well as location could help distinguish them, but would need explicit handling for moves, deletion, and identifier reuse. This is a possible improvement; 1.0.0 tracks only names.
Watch directory changes and debounce rescans
Bare opens the Desktop directory with O_EVTONLY and registers a DispatchSource for write, rename, delete, and link events. When hiding and auto-hide are enabled, a directory event schedules another application of the selected categories.
The watcher implementation cancels pending work and schedules the rescan after 0.4 seconds. This groups bursts of filesystem activity. Repeated events can postpone the operation further, so a newly saved screenshot may briefly be visible.
The isolated runner created a new file with a recognized screenshot name while watching was active. It acquired the hidden flag within the test's two-second window. This checked one new-file event, without measuring latency under load.
Showing icons on quit preserves the saved mode
When Show Icons When Quitting is enabled, applicationWillTerminate calls apply(forceShow: true). For that call, the selected category set is empty, so Bare restores tracked files without changing the saved isHiding preference.
The runner confirmed that a forced Show restored visibility while the hiding preference stayed enabled. Applying the saved mode hid the matching file again. The launch path also applies that saved mode.
A normal quit gives Bare a chance to run that cleanup. A crash or forced termination may skip it. Persistent tracking lets a later launch attempt restoration, subject to the filename and directory limitations above. Keep the app's saved settings until the files are visible again.
Disk icons use a separate mechanism
Mounted disks and servers are handled through Finder preferences. Bare reads four display preferences, saves the values it finds, writes them as false, and relaunches Finder. Restoring them writes the saved values back; a preference with no saved value is removed so Finder can use its default.
Ordinary file hiding notifies Finder of a filesystem change. Also Hide Disks & Servers changes Finder preferences and runs killall Finder.
The isolated runner kept drive hiding disabled. Its results do not verify mounted-volume restoration or Finder relaunch behavior. Those details here come from the versioned source.
What the isolated checks established
The runner completed thirteen assertions against the unmodified production source on the named Mac. They covered selective hiding, preservation of a previously hidden item, other file flags, unchanged file bytes, symbolic links, forced restoration, the rename limitation, preservation of tracking after a failed scan, and one new-file watcher event.
The checks used controlled test files and did not exercise iCloud synchronization, multiple displays, a system crash, permission revocation, or a competing Desktop utility. The screenshot fixture had a recognized filename and a small known payload. It tested filename classification and flags without decoding an image.
Reproduce the filesystem checks
The isolated Swift runner creates a temporary directory and passes it to the production class's existing Desktop initializer. It disables drive handling and skips old-settings migration. To build it with Bare's unchanged 1.0.0 source, run these commands on a Mac with the Xcode command-line tools:
experiment_dir="$(mktemp -d)"
git clone --depth 1 --branch v1.0.0 \
https://github.com/orlandoascanio/Bare.git "$experiment_dir/Bare"
curl -fsSL \
https://www.orlandoascanio.com/examples/bare-file-flags/main.swift \
-o "$experiment_dir/main.swift"
cd "$experiment_dir/Bare"
swiftc Sources/Bare/DesktopHider.swift \
Sources/Bare/Classifier.swift Sources/Bare/Settings.swift \
Sources/Bare/Shortcut.swift Sources/Bare/HotKey.swift \
"$experiment_dir/main.swift" -o "$experiment_dir/BareEvidence"
"$experiment_dir/BareEvidence"
The runner prints each assertion and the location of its retained fixtures. It changes flags only inside that fixture directory and writes its own test preferences. It does not operate on the real Desktop or launch Bare's menu bar interface.
You can inspect the hiding implementation, classification rules, and quit handling. If a file needs to become visible again, use the restore-icons checklist.
A tiny vote of confidence
Was this note worth your time?