How I put a physics-simulated cloth rug on my Mac desktop
Before every screen share or video call, the first thing everyone sees is my desktop — and it's a mess. I wanted a way to just… cover it. Not hide icons in a dock autohide trick, but literally throw a rug over the clutter. So Desk Rug is a small native macOS app that puts a live, physics-simulated cloth rug on your desktop. One hotkey sweeps the icons underneath it; another brings them back. The…
When meeting for screen shares or video calls, the first thing anyone notices is the cluttered desktop behind the apparent mess. To address the visual disorder, I sought a solution to place a rug over the disorderly icons on the desktop. Desk Rug is a compact native macOS application that simulates a live, physics-based cloth rug, concealing the cluttered icons beneath it.
Initially, I didn't start from scratch; instead, I took inspiration from the MIT-licensed under-the-rug by siliconbag, a remarkable concept that required further development. My task was to dissect and reconstruct the project, focusing on areas that needed improvement such as solver stability, startup speed, CPU usage, and overall functionality.
The rug is composed of a grid of vertices that are simulated using XPBD (substepped, similar to the Ten Minute Physics cloth), rather than a pre-baked animation. The grid consists of 56 columns with a spacing of approximately 19pt, which is sufficient to deform the fabric, creating visible creases and folds. The surface below the rug is a signed height field with both static and kinetic Coulomb friction, ensuring that the rug settles, remains stationary, and slides naturally like actual fabric.
Icon piles create bumps on the height field, mimicking the effect of hidden icons beneath the rug, giving the illusion of a bulge. To maintain accuracy, self-collisions are resolved using a spatial hash, preventing the folds from intersecting each other. All coordinates in the simulation are in screen points, maintaining consistency with the desktop's units, which facilitates smooth dragging, grabbing, and releasing of the fabric.
Rendering is accomplished through Metal Shading Language (MSL) compiled at runtime from a source string, eliminating the need for a Metal toolchain or precompiled bundle. The rug features a soft directional light, a 16-tap Poisson soft shadow, and a procedural fragment pass to achieve the fleece appearance on top of the vertex grid.
Various modifications were made from the original project: improved solver stability through tighter substep budgets, velocity caps, and a maxSpeed guard; a leaner grid and rendering path to reduce CPU usage nearly to zero; six different rug and floor options, along with the ability to import custom images for both (treating them as UV-mapped fabrics).
Additionally, a per-day schedule was implemented to automatically hide and reveal icons before meetings and restore them afterward. The app also supports per-Space profiles, adjusting rug, floor, and size settings based on the current desktop space.
Icons are moved and restored using Finder, ensuring they are not deleted and positioned precisely around the screen edge. A global hotkey (⌃⌥⌘R) is available for immediate access through Carbon. The app is available in 12 languages, and it was developed in 13 interface languages. The cloth parameters are exposed through environment variables (RUG_G, RUG_BEND, RUG_DAMP, RUG_COLS, etc.), allowing for real-time adjustments without needing a recompile.
Privacy is a top priority - the app does not require any accounts, analytics, network calls, or screen-recording permissions, and it operates entirely within the Finder on your machine without transmitting any data.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.