How do I pin my favorite folders in Ubuntu dock like in Windows?

Solution 1:

Follow the steps below.

  1. Create a .desktop file (say custom-filemanager.desktop) in ~/.local/share/applications. You can do this by running the following command in Terminal

    touch ~/.local/share/applications/custom-filemanager.desktop
    
  2. Open the .desktop file using a text-editor, for example by running

    gedit ~/.local/share/applications/custom-filemanager.desktop
    
  3. Add the following lines to the file:

    [Desktop Entry]
    Name=File Manager
    Comment=Access and organize files
    Keywords=folder;manager;explore;disk;filesystem;
    Exec=nautilus --new-window %U
    Icon=org.gnome.Nautilus
    Terminal=false
    Type=Application
    Categories=GNOME;GTK;Utility;Core;FileManager;
    Actions=new-window;open-downloads;
    
    [Desktop Action new-window]
    Name=New Window
    Exec=nautilus --new-window
    [Desktop Action open-downloads]
    Name=Open my Downloads folder
    Exec=nautilus /home/YOUR-USER-NAME/Downloads
    

    Replace YOUR-USER-NAME by your user-name in the last line.

  4. Save the file.

  5. Click on "Activities" and search for "File Manager". It should appear.

  6. Right click on the "File Manager" and select "Add to Favourites". It should be added to the dock.

Now if you right click on the newly added File Manager icon in the dock, you should see a "Open my Downloads folder" option which should work as expected.

enter image description here

Similarly you can add shortcuts to other locations by adding new Desktop Actions and adding the name of the action to the Actions= line. For more info see this.

Solution 2:

As we can pin only Application to Gnome Dock, the best available option here is creating an application launcher that will open the favorite directory directly with a single mouse click.

  1. So in order to do that navigate to activities and search for "Main menu".

    screenshot

    Now you will get a window titled Main menu.

  2. Click on New item. and You will get a small window and fill the fields like described below.

    In the given example I am pinning my Videos directory to Dock.

    screenshot

    And now it will be shown at the bottom of the main menu window like this

    screenshot.

  3. Click on close button and again go to activities and search for the the "Name" provided. In my case its "My Videos". Single click on that and just drag and drop it to the Gnome dock.

    Now You will get the shortcut on your Dock.

    screenshot

If you click on that you will get your favorite directory which you set opened by nautilus.

Tweaks

You can do more tweaks like changing the icon of the application launcher you want while creating the shortcut of even after creating the shortcut and pinning it.

After tweaking my shortcut (My Videos) is like this.

screenshot

Solution 3:

Here is how to make it in Ubuntu 18.04:

  1. Open Files, press Ctrl+L and paste /usr/share/applications.

  2. Look for the "Files" icon and copy it (right click > Copy)

    Note: in my system, I don't know why, there are tree "Files" icon. For this procedure I selected the first one, which has 2,7kB. To make sure it'll work in your computer I recommend you to do the same.

  3. Now open your personal folder and press Ctrl+H to show hidden files.

  4. Once you've done it, navigate to .local/share/applications and paste the file you copied in the step 2 into this folder.

  5. You'll see a new icon called org.gnome.Nautilus.desktop. Right click on it and select "Open with other application". Select the Text Editor to open it and replace the content of the file with the following:

    [Desktop Entry]
    Name=Files
    Comment=Access and organize files
    Keywords=folder;manager;explore;disk;filesystem;
    Exec=nautilus --new-window %U
    Icon=org.gnome.Nautilus
    Terminal=false
    Type=Application
    Categories=GNOME;GTK;Utility;Core;FileManager;
    StartupWMClass=nautilus;Nautilus
    Actions=new-window;open-documents;open-downloads;open-pictures;open-music;open-videos;
    
    [Desktop Action new-window]
    Name=New window
    Exec=nautilus --new-window
    
    [Desktop Action open-documents]
    Name=Documents
    Exec=nautilus /home/YOUR-USER-NAME/Documents
    
    [Desktop Action open-downloads]
    Name=Downloads
    Exec=nautilus /home/YOUR-USER-NAME/Downloads
    
    [Desktop Action open-pictures]
    Name=Pictures
    Exec=nautilus /home/YOUR-USER-NAME/Pictures
    
    [Desktop Action open-music]
    Name=Music
    Exec=nautilus /home/YOUR-USER-NAME/Music
    
    [Desktop Action open-videos]
    Name=Videos
    Exec=nautilus /home/YOUR-USER-NAME/Videos
    

    Replace YOUR-USER-NAME by your username.

  6. Save the document and close it. You're done!

Note: If your system is in another language that not English replace the words of the filds Name= and Exec= of the desired [Desktop Action] for the equivalent in your language. See an example in Portuguese above:

[Desktop Action open-pictures]
Name=Pictures
Exec=nautilus /home/YOUR-USER-NAME/Pictures

Is going to be:

[Desktop Action open-pictures]
Name=Imagens
Exec=nautilus /home/YOUR-USER-NAME/Imagens

Finally, replace the word of the field Name=Files of [Desktop Entry] according to what Files means in your language. In Portuguese, for example, Files is translated Arquivos, so I had to change Name=Files to Name=Arquivos. If you don't do this, you'll end up with two Files icons with different names in your computer.


Final result

enter image description here