3

In Chrome and Gnome Terminal, I want to add context menu entries to search Youtube. Any pointers as to how that can be done?

1 Answers1

0

This can be done by adding sections describing desktop actions to the launcher of the application. For example, the launcher of the Google Chrome application contains a few such sections to add the "New Window" and "New Incognito Window" sections, like:

[Desktop Entry]
Version=1.0
...
Actions=new-window;new-private-window

[Desktop Action new-window] Name=New Window Exec=/usr/bin/google-chrome-stable

[Desktop Action new-private-window] Name=New Incognito Window Exec=/usr/bin/google-chrome-stable --incognito

By adding your own [Desktop action ...] sections, you can add additional right-click options or modify the existing ones.

Copy the launcher to your ~/.local/share/applications if you are the only user needing the additional right-click items. You can then copy and customize the launcher as a normal user.

If you wish to make the change available systemwide, then modify a copy of the launcher in /usr/local/share/applications. You need to create the folder as it does not exist by default in Ubuntu. You could also edit the installed launcher directly, but it may be overwritten on a subsequent update. You need root permissions to make these system wide changes.

vanadium
  • 88,010
  • Per the Desktop Entries Specification (https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html), "It is not valid to have an action group for an action identifier not mentioned in the Actions key." So for instance here, you would also need, in the main [Desktop Entry] group, a line with at least Actions=new-window;new-private-window – rakslice Dec 04 '23 at 06:25
  • 1
    @rakslice, thanks for the comment. That is an omission that I will correct in the answer – vanadium Dec 04 '23 at 07:05