How to set default opening folder for Nautilus file manager?

How do I configure Nautilus to open at my Documents folder instead of my home folder?

I've scoured this site and found answers instructing users to edit the /usr/share/applications/nautilus.desktop file, replacing %U with the path to the desired default directory. I've edited all the variants of nautilus.desktop in the said directory, but none of the edits has an effect. I've checked all the files after editing them to make sure that I saved the edit effectively, and all look good to me.

I've edited every file to read as follows:

Exec=nautilus --new-window /home/judy/Documents

I've also edited the org.gnome.Nautilus.desktop file, just to be sure, with no joy.

I'm running Ubuntu 15.10.

Note: if I enter nautilus /home/judy/Documents from the command line, Nautilus properly opens in the desired directory. Is there a simple way that I can configure an icon in the launcher bar to run this command and have the Nautilus icon that looks like a metal file drawer?

Thanks. I'm pulling my hair out over this one.


Solution 1:

The file that is shown in unity-dash is not anymore /usr/share/applications/nautilus.desktop but /usr/share/applications/org.gnome.Nautilus.desktop.

Changing the Exec= line in the file itself does not have any effect. The problem is an entry DBusActivatable=true that makes the system to run nautilus via dbus. So the Exec= line is being ignored. Maybe it is possible to provide nautilus the desired directory through dbus (/usr/share/dbus-1/services/org.gnome.Nautilus.service) but I am not familiar with that system in detail.
For further information look here: https://wiki.gnome.org/HowDoI/DBusApplicationLaunching

A simple solution for me was to hide the gnome/dbus launcher-icon and make the old one visible again. So add the entry NotShowIn=Unity; to /org.gnome.Nautilus.desktop and comment it out in nautilus.desktop. There you can adjust the Exec= line with the desired directory.

(file: org.gnome.Nautilus.desktop)

[Desktop Entry]
NotShowIn=Unity;     # <--------------------------- add this line !
Name=files
Comment=Access and organize files
Keywords=folder;manager;explore;disk;filesystem;
Exec=nautilus --new-window %U
Icon=system-file-manager
Terminal=false
Type=Application
DBusActivatable=true
StartupNotify=true
Categories=GNOME;GTK;Utility;Core;FileManager;
MimeType=inode/directory;application/x-gnome-saved-search;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=nautilus
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=3.14.2
X-GNOME-UsesNotifications=true
Actions=Window;
X-Unity-IconBackgroundColor=#af4853
X-Ubuntu-Gettext-Domain=nautilus

#OnlyShowIn=Unity;    # <---------------- comment out this line !

[Desktop Action Window]
Name=Open a New Window
Exec=nautilus --new-window
#OnlyShowIn=Unity;    # <---------------- comment out this line !

(file nautilus.desktop)

[Desktop Entry]
#NotShowIn=Unity;     # <---------------- comment out this line !
Name=files
Comment=Access and organize files
Keywords=folder;manager;explore;disk;filesystem;
Exec=nautilus --new-window /{DESIRED_DIRECTORY}     # <- adjust !
Icon=system-file-manager
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Utility;Core;FileManager;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=nautilus
X-GNOME-Bugzilla-Component=general
X-GNOME-Bugzilla-Version=3.14.2
X-GNOME-UsesNotifications=true
Actions=Window;
X-Unity-IconBackgroundColor=#af4853
X-Ubuntu-Gettext-Domain=nautilus

[Desktop Action Window]
Name=Open a New Window
Exec=nautilus --new-window

Solution 2:

Here is what worked for me on a vanilla Ubuntu 20.04:

(Worth noting that while on the UI the app is called "Files", under the hood it's still referred to as nautilus.)

1.: Copy the right launcher to the right location:

/usr/share/applications/org.gnome.Nautilus.desktop

to

/home/<YOURUSERNAME>/.local/share/applications/

2.: Make the copy executable, either with:

chmod +x /home/<YOURUSERNAME>/.local/share/applications/org.gnome.Nautilus.desktop

or by right-clicking the icon > Properties > Permissions tab > Checkbox "Allow executing file as program".

3.: Edit the copy:

3.a: there are two lines that start with Exec=. Edit both lines so they look like this:

Exec=nautilus --new-window /your/desired/directory

Note that I removed the %U from the end of the line.

3.b: Deal with the DBusActivatable entry (thanks L31N).

Either assign a false value to it, or comment out the line, like this:

# DBusActivatable=true

I don't know know about any side effects of this latter step, I hope it's gonna be fine in the long run.

4.: Either reboot or just log out of the session and log back in.

For me now it opens my directory both when called via the dash and when clicked in the dock.

Solution 3:

Trying to make this work for a while now. After a lot of frustration, stumbled on something that worked for me:

  • changed all the "Exec" commands in all the files that start with "nautilus"

    Exec=nautilus-autorun-software /home/user/Desktop

  • deleted all existing "Files" icons from my Desktop and /home/user/.local/share/applications folder (had quiet a few of them due to past tries to solve this issue that did not work)

  • changed 3 lines in /usr/share/applications/org.gnome.Nautilus.desktop:

    Exec=nautilus --new-window /home/user/Desktop DBusActivatable=false ... Exec=nautilus --new-window /home/john/Desktop/repos

Note: the Exec command apear twice in org.gnome.Nautilus.desktop! one time at the very last line. changed both.

  • restarted the computer

  • started files from activities (Activities -> Type here to search... -> "Files") and it worked.

I added the Files icon to favorites (with right click -> add to favorites) and it opens the correct folder every time.

This is my org.gnome.Nautilus.desktop file after the change:

   [Desktop Entry]
   Name=Files
   Comment=Access and organize files
   # Translators: Search terms to find this application. Do NOT translate or 
   localize the semicolons! The list MUST also end with a semicolon!
   Keywords=folder;manager;explore;disk;filesystem;
   Exec=nautilus --new-window /home/user/Desktop
   # Translators: Do NOT translate or transliterate this text (this is an icon 
   file name)!
   Icon=org.gnome.Nautilus
   Terminal=false
   Type=Application
   DBusActivatable=false
   StartupNotify=true
   Categories=GNOME;GTK;Utility;Core;FileManager;
   MimeType=inode/directory;application/x-7z-compressed;application/x-7z- 
   compressed-tar;application/x-bzip;application/x-bzip-compressed-tar;a$
   X-GNOME-UsesNotifications=true
   Actions=new-window;
   X-Unity-IconBackgroundColor=#af4853
   X-Ubuntu-Gettext-Domain=nautilus

   OnlyShowIn=Unity;GNOME;

   [Desktop Action new-window]
   Name=New Window
   Exec=nautilus --new-window /home/user/Desktop/repos

Hope it will help.