GrabFS: The Screenshot File System

© Amit Singh. All Rights Reserved. Written in December 2007

Processes as Files

A while ago, I wrote about procfs for Mac OS X, a MacFUSE-based file system. Subsequently, I added more cool features to my procfs implementation. Recently, I had reason to demonstrate procfs again and realized that I needed still more cool features. That need led to GrabFS.

Screenshots as Files

In a pinch, GrabFS is a file system that shows you a live view of the window contents of currently running applications. In a GrabFS volume, folders represent running applications and image files represent instant screenshots ("grabs") of the applications' windows. You simply copy a file or just open it in place, and you have a screenshot. Open it again, and you have a new screenshot!

GrabFS requires Mac OS X "Leopard" and MacFUSE.

GrabFS Volume Icon When you launch the GrabFS application, it mounts a volume that's visible on your Desktop as GrabFS Volume. Of course, GrabFS being a "real" file system, you can just as well access it from the Terminal—it's mounted on /Volumes/GrabFS/. To eject this volume, as you normally would, use one of the several ways possible on Mac OS X—drag it to the Trash, or select the icon and type ⌘-E, or use /sbin/umount on /Volumes/GrabFS/.

At the top level of the GrabFS volume, you will see several folders—each corresponds to a running application. A folder's name incorporates the corresponding application's name and its BSD process identifier. For example:

$ ls /Volumes/GrabFS Adium (341)/ SystemUIServer (113)/ AirPort Base Station Agent (120)/ Terminal (144)/ Dock (112)/ WindowServer (84)/ Finder (114)/ iTunes Helper (121)/ Preview (1520)/ loginwindow (32)/ Safari (339)/ mdworker (1505)/ Spotlight (107)/

Graphically speaking:

GrabFS Root Folder
GrabFS Root Folder

Within each folder you will see zero or more TIFF files—one for each onscreen window the application currently has. The files are named <window_id>.tiff, where <window_id> is the global window identifier for that window. Each such file, when opened, will consist of that window's contents at the moment the file is opened. In other words, these files are akin to live, in-place screenshots. "Grabbing a screenshot" becomes merely opening the file in the application of your choice. You can open these files in place, or copy them over to somewhere. Copying a file N times gives you N screenshots taken at N moments in time. (Note that GrabFS is a read-only file system.)

$ ls -las /Volumes/GrabFS/Safari\ \(339\)/ 0 drwxr-xr-x 1 root wheel 0 Dec 31 01:04 . 0 drwxr-xr-x@ 1 root wheel 0 Dec 31 01:04 .. 6144 -rw-r--r-- 1 root wheel 3143192 Dec 31 01:04 40a.tiff 6144 -rw-r--r-- 1 root wheel 3143192 Dec 31 01:04 5ef.tiff 6144 -rw-r--r-- 1 root wheel 3143192 Dec 31 01:04 5f2.tiff $ sips -g all /Volumes/GrabFS/Safari\ \(339\)/40a.tiff /Volumes/GrabFS/Safari (339)/40a.tiff pixelWidth: 950 pixelHeight: 825 typeIdentifier: public.tiff format: tiff formatOptions: default dpiWidth: 72.000 dpiHeight: 72.000 samplesPerPixel: 4 bitsPerSample: 8 hasAlpha: yes space: RGB profile: Color LCD

Again, graphically speaking:

Contents of the Safari Folder in Grabfs
Contents of the Safari Folder in GrabFS

You will see that the number and names of TIFF files reflect the current state of things. As an application's onscreen windows come and go, the corresponding TIFF files appear and disappear, respectively, from that application's GrabFS folder. Besides, each time you go to the Finder window for a GrabFS folder, you will see that the preview images (including what you see in Cover Flow) are updated to the current window contents. Since the files in question are "real" image files for all intents and purposes, Mac OS X features such as Quick Look will work fine as well.

Quick Look on a GrabFS File
Quick Look on a GrabFS File

An interesting use of GrabFS is to discover which of the entities you see onscreen are "windows" and who owns them. For example, you will see that each icon on the Desktop is a window belonging to the Finder—you will find TIFF files for each within the Finder folder. If you look inside the WindowServer folder, you will see a window corresponding to your Desktop background, a window corresponding to the now infamous "translucent" menu bar, and another corresponding to the menu bar's shadow. Within the SystemUIServer folder, you will see a window like the following.

A SystemUIServer Window
A SystemUIServer Window

As can be seen, not all "icons" in the menu bar come from SystemUIServer. The Spotlight icon on the top right corner of the screen can be found within the GrabFS folder for the Spotlight application.

Summing Up

The purpose of GrabFS is to be an interesting utility and a demonstration of the kind of things you can do with MacFUSE. Have fun with it!

More Reading

A MacFUSE-Based Process File System for Mac OS X

Making procfs Cooler


You must read and agree to this site's terms and conditions before downloading or using any software or other material available from this site.

GrabFS-1.0.dmg contains a Leopard-only Universal binary of GrabFS. You will need the Leopard version of MacFUSE to run GrabFS.