How to set default opening folder for Nautilus file manager?

144

Solution 1

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 2

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 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.

Share:
144

Related videos on Youtube

Swantewit
Author by

Swantewit

Updated on September 18, 2022

Comments

  • Swantewit
    Swantewit over 1 year

    As @vadian suggested, I am learning Xcode from Paul Hudson's 100 days of SwiftUI to better understand the basics (even though I am still struggling with time to deliver working GitHub repository search - no it is not for the job I am working on right now).

    I am doing a lesson on Arrays, so pretty basic stuff right now and I struggle to map the String from array on the sorted array. I don't get why, but I get the:

    Ambiguous use of 'init'
    

    error.

    Here's the code:

    let cities = ["London", "Tokyo", "Rome", "Budapest"]
    print(cities.sorted())
    
    let citiesSorted = cities.sorted()
    
    let citiesSortedString = citiesSorted.map(String.init).joined(separator:", ")
    

    And it's so really strange, since I pulled the similar thing out before in the same Playground but not with the sorted Array:

    var schoolScoresString = schoolScores.map(String.init).joined(separator:", ")
    print(schoolScoresString)
    

    And yes I tried changing let to var. It didn't help.

    • Admin
      Admin over 8 years
      Did you try a restart after making these changes?
    • Admin
      Admin over 8 years
      Also, if you just run nautilus --new-window /home/judy/Documents in Terminal does it work as desired?
    • Jacob Vlijm
      Jacob Vlijm over 8 years
      To my surprise, the way it used to work doesn' t anymore. WIll remove my answer, will post back if I find out why.
    • trinkner
      trinkner over 8 years
      Thanks for the advice. I've edited the original nautilus desktop files in /usr/share/applications back to their default state. I've copied the org.gnome.Nautilus.desktop file into my ~/.local/share/applications directory and used gedit to edit its Exec line. I've rebooted. I've run the source ~/.profile command. Sadly, still no joy. When I start nautilus from the launcher bar, it still starts in my home directory instead of in my documents directory.
    • trinkner
      trinkner over 8 years
      Here is the contents of the file:[Desktop Entry] Name=Files Comment=Access and organize files Keywords=folder;manager;explore;disk;filesystem; Exec=nautilus --new-window /home/judy/Documents 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 etc... the web site doesn't let me add more chars.
    • Jacob Vlijm
      Jacob Vlijm over 8 years
      @trinkner see my comment above, I am quite surprised myself, just tested it. There must be a change since 15.04. I will try tg find out how to set the defailt directory. The content of the Exec= line is ignored...
    • trinkner
      trinkner over 8 years
      Bump. Is there any better answer to this? If this is a bug, how do I report a bug to the developers? (My apologies, but I don't know enough about programming in Ubuntu yet to contribute a fix myself.)
  • Jacob Vlijm
    Jacob Vlijm over 8 years
    Sorry, but this is really bad. Never have multiple .desktop files represent the same application in their main command. It will mess up the presence of nautilus in the launcher.
  • L31N
    L31N about 8 years
    @trinkner I do not know for what each file exactly is, but these are different launcher-icons for different uses. nautilus-home.desktop e.g. is used for the home-icon in the launcher (open it and look at the comment). You can also create new icons for specific locations. You only have to copy nautilus.desktop and replace %U with the directory. To find it in the dash you have to make sure that there is no entry NotShowIn=Unity.
  • trinkner
    trinkner about 8 years
    I succeeded in getting Nautilus to open to my desired folder by making the edits suggested by @techraf. But after the edits, Nautilus continued to open at the default /home/user directory when launched from a pinned launcher bar icon. To solve this, I renamed EVERY nautilus .desktop file in /usr/share/applications by appending .backup to the file name. I appended .backup to the org.gnome.Nautilus.desktop file name. The one file I did not rename was nautilus.desktop, which I edited as suggested by @techraf. Now the launcher icon correctly opens in my desired folder.
  • Trevor Hickey
    Trevor Hickey almost 6 years
    That didn't work either. I'm on ubuntu 18 LTS. This whole thing has been ridiculous. I've tried 30 different things, but I still can't click on a desktop folder and open it. It's amazing to watch time go on and technology regress into uselessness. I thought opening inode/directories was a solved problem. Maybe I'll wait till the next LTS.
  • qba-dev
    qba-dev almost 3 years
    That was helpful. In my case I don't use launcher, but have keys assigned like in windows explorer (Windows+E). Only thing I had to do, was edit key combination command adding desired folder. Thanks
  • vanadium
    vanadium over 2 years
    There is no need to make the .desktop file executable: Step 2 can be removed.