1

Observe:

  1. Open Files/Nautilus.
  2. Right-click on the Files icon in the Dock.
    Result: In the context menu, you see All Windows at the top in its own section, New Window at the top of the next section (followed by a list of folders), either Add to Favorites or Remove from Favorites in the next section, and Quit in the bottom section.
    Note: this content remains intact indefinitely.
  3. Click Add to Favorites if necessary.
  4. Close the Files/Nautilus window.
  5. Right-click the Files shortcut in the Dock/Favorites.
    Result: a similar context menu as before appears, except without the All Windows and Quit sections. See below for a screenshot.
  6. Wait a few seconds.
    Result: all folders disappear from the menu - the only remaining options are New Window and Remove from Favorites.

How do I prevent the folders from disappearing from this context menu?

sample context menu from step 5:

enter image description here

user68186
  • 33,360

1 Answers1

0

You cannot prevent the folders from disappearing from this context menu. Files, i.e., nautilus, must be running for these items to appear on the right-click menu.

Since Files does not anymore control the desktop, it is not anymore running when you closed all windows. That makes the current behavior of the right-click menu inconsistent in the way you observe. That is, however, an issue that needs to be solved at the level of the Ubuntu Dock Gnome Shell extension, which is the software implementing this behavior.

Probably, that behavior should be removed. Instead, "fixed" right-click menu items to quickly access these folders could be added as "Desktop actions" in the .desktop launcher file. Such right-click items, unfortunately, are static, and need to be updated manually.

Note When closing the last windows, it indeed takes several seconds before the nautilus process itself is terminated. That is why you need to wait a few seconds before the items do not anymore appear.

vanadium
  • 88,010
  • "fixed" right-click menu items to quickly access these folders could be added as "Desktop actions" in the .desktop launcher file: I'd be fine with fixed ones - I think I'd prefer them, actually. where are the .desktop files for folders, and what line do you need to add to them? – mathlete Sep 13 '23 at 18:06
  • There is a great guide on how to edit the .desktop file to create a fixed right-click menu here: https://askubuntu.com/questions/1180311/how-do-i-add-new-locations-to-right-click-menu-of-files-launcher-in-ubuntu-doc

    This works perfectly with Ubuntu 20.04 and older. However, with 22.04 and above, it does add the fixed shortcuts you create, but when you open Files/Nautilus it still adds all the default locations and bookmarks from the Files application in addition to your custom shortcuts. This results in many duplicates in my case and a very messy menu.

    – James Jan 24 '24 at 15:44