Nautilus Window Restoring

Is it really that hard for a program to restore the windows that were open when you logged out? One of the things I liked about OS X was that it remembered the open file manager windows and folders. The default file manager on Ubuntu, Nautilus (Gnome Files), doesn’t do that. It just opens your Home folder. I wrote a couple of python scripts to remedy the situation.

Step one was to figure out how to determine the folders that were open. I found a Nautilus D-Bus entry that contains the window ID and folder for each open window.

The next step was to get the window positions and sizes. For this I used Xlib.

The source code is in the NautilusWinMon github project.

This is a Nautilus LocationWidgetProvider that gets notified whenever the user changes folders in a window. This spawns to save the current window positions/sizes and folders. This has to be done asynchronously because otherwise the Nautilus process would be talking to itself via D-Bus and would deadlock until D-Bus timed out.

This is called asynchronously by and saves the current Nautilus window positions and folders to a configuration file. It uses D-Bus to get the window IDs and folders. Then uses Xlib to get the window positions and sizes.

This is called at login to restore the Nautilus windows. It shell execs nautilus for each window/folder, then uses Xlib to position and size each window.


The Ubuntu window manager Compiz, places an invisible 8 pixel border around a resizable window to capture window resizing events. When programmatically positioning a window, Compiz will not let you move the resizing border offscreen. When positioning a window manually, Compiz will let you move the resizing border off screen. This means that even though you can position a Nautilus window in a corner with no visible gap, when the window is restored, the resizing gap will appear.