41

I'm running Ubuntu 13.04 with Nautilus 3.6 and I want to edit the Nautilus Places sidebar menu (Not Bookmarks).

By default have the following items: Recent, Home, Desktop, Documents, Downloads, Music, Pictures, Videos & Trash.

I wish:

  • Add folder to Places (Not Bookmarks).
  • Added Folder must be present in Unity QuickList (Right Click Nautilus icon in Launcher).
  • Remove Recent files (Default in Nautilus 3.6).
  • Rename Trash to another name.

how can I achieve these goals?

NOTE: I tried editing ~/.config/user-dirs.dirs file, but not luck. Is there another way to customize Nautilus Places menu?

0

5 Answers 5

42

In order to achieve that.. you should edit the Nautilus source code and the nautilus.desktop file or using another file manager that allows this, such as nemo.


NOTE: In this example I'm running ubuntu 13.04 with nautilus (files) 3.6.3.
You can test this in a virtual machine to see if everything is OK.


1) Make sure you have enable the Source code repository

  • Open the Ubuntu Software Center
  • In the Menu Bar choose Edit -> Software Sources. Click to enable "Source code repository". Just in case I use the "Main Server" to Download.

enter image description here

Open a Terminal Window to update the repositories.

  • sudo apt-get update

2) In the Terminal type the following to install the necessary packages.

  • sudo apt-get install build-essential quilt

3) Install build dependencies.

  • sudo apt-get build-dep nautilus

4) Create a folder to download the source code.

  • mkdir ~/Downloads/src

  • cd ~/Downloads/src

5) Download the source code & Export variables.

  • apt-get source nautilus

  • export QUILT_PATCHES=debian/patches

  • export EDITOR=gedit

6) Create the patch and edit the source code.

  • cd nautilus-3.6.3/

  • quilt new my_custom_places.patch

  • quilt edit src/nautilus-places-sidebar.c


Custom Trash: To change the name of the Trash.You can change the strings in the lines 567 and 569.

eg: "Trash" to "Custom Trash" & "Open the trash" to "Open the Custom Trash"

enter image description here


Add Folder: In this example I will add the "Test" folder in my home directory /home/virtual/Test. (change the folder according to your needs)

After the line number 562 add the following:

/* add Test directory */
mount_uri = "file:///home/virtual/Test";
icon = g_themed_icon_new (NAUTILUS_ICON_FOLDER);
add_place (sidebar, PLACES_BUILT_IN,
       SECTION_COMPUTER,
       _("Test"), icon, mount_uri,
       NULL, NULL, NULL, 0,
       _("Open Test folder"));
g_object_unref (icon);

enter image description here


Remove Recent Files: To remove the Recent Files from the places... delete the lines from 525 to 534.

enter image description here

Save the changes.


7) Build the deb packages.

  • quilt refresh
  • fakeroot dpkg-buildpackage

8) Install the deb packages.

  • cd ..

  • sudo dpkg -i *deb

9) For system-wide..edit the nautilus.desktop file to add the folder eg:(/home/virtual/Test) in the quick list.

  • sudo nano /usr/share/applications/nautilus.desktop

Change:

Actions=Window;

To:

Actions=Test;Window;

Add:

[Desktop Action Test]
Name=Test             
Exec=nautilus --new-window /home/virtual/Test
OnlyShowIn=Unity;

Before:

enter image description here

After:

enter image description here

10) Finally you can logout and Login to see the changes.

RESULT:

enter image description here

Hope this helps.

4
  • My version of nautilus is nautilus-3.10.1. In step #6 after I cd nautilus-3.10.1 and then run ls src from there I find that nautilus-places-sidebar.c is not found in the source. Where do I make the changes listed in step #6 above for nautilus 3.10.1 in Ubuntu 14.04 LTS? My goal here is to just add a directory to the places sidebar.
    – Willoczy
    May 21, 2014 at 8:20
  • would be cool, to see how this works with nautilus 3.10
    – wa4557
    Aug 10, 2014 at 12:59
  • 4
    Just curious whether this is something related to security or not...this is avery elaborate procedure for a relatively straightforward (requirement-wise not implementation) customization feature. Aug 25, 2014 at 13:40
  • @Roman Raguet Kindly update the same for Ubuntu 14.04 askubuntu.com/questions/516999/… Sep 12, 2014 at 6:15
11

I found an easy way outlined on SO.

Please follow the instructions outlined in this link - this solved the same problem I had.

Excerpts:

gedit ~/.config/user-dirs.dirs

Remove the list you do not want. However, once you login again, it will reset, so

echo "enabled=false" > ~/.config/user-dirs.conf
4
  • cool! a pity is doesnt have the trash folder so I could disable it :) Mar 11, 2015 at 21:48
  • Thank you, this is a reasonable answer and works great in 14.04. This is not 1999; I'm done with recompiling my operating system just to make it work!
    – Lambart
    Aug 31, 2015 at 17:53
  • 1
    Also note that you'll need to kill and restart nautilus for these changes to take effect: pkill nautilus should do the trick.
    – Lambart
    Aug 31, 2015 at 18:09
  • I don't have a ~/.config/user-dirs.conf and I'm running 14.04. Do I create it? Oct 20, 2015 at 14:08
2

For nautilus of ubuntu 14.04, you will have to edit gtk3.10, the same way as stated above, as the SideBar functionality was now ported into gtk (so that the file-open dialogue sidebar and the nautilus-sidebar are not separated implementations any more)

edit /gtk/gtkplacessidebar.c

I also tried this http://pastebin.com/K4GcHrz7 in nautilus-window.c, as there is https://developer.gnome.org/gtk3/stable/GtkPlacesSidebar.html#gtk-places-sidebar-add-shortcut but get a segfault, not a good (gtk) programmer though.

1
  • pastebin link has been removed! Sep 12, 2014 at 6:01
2

On my system (Ubuntu 14.04.1 LTS), the file you want is found at ~/.config/gtk-3.0/bookmarks Older versions used to keep this in ~/.gtk-bookmarks. Entries are URIs, so filepaths must be absolute and prefixed with file://.

1
  • 1
    This is incorrect at best. A red flag should have been thrown when you typed the file names: they share a word with what the OP explicitly stated, he does not want - Not Bookmarks. Please read the question and answers before polluting the global namespace. Jul 14, 2015 at 6:16
0

Just drag and drop the files to the bottom left when at a folder! (Nautilus 2.32.0)

I also posted the screenshots at gonorthwork/view for future archive reference:

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.