1

In windows, you can and context menu entries that are only shown for specific file types only.

In Dolphin, I know how to add service menu entry using .desktop file. but Is there way to only show those service menus for specific file type?

  • odd that it wasn't answered yet. when this happens again try other stackexchage sites like askubuntu and superuser – user32012 Feb 7 '17 at 15:26
1

Under the section [Desktop Entry] should be the line that specifies the type of file for which that appears: MimeType=.

To limit that to mp4 files, it should be MimeType=video/mp4. To restrict to all videos: MimeType=video/*; to videos AND folders:MimeTypevideo=video/*;inode/directory;.

Also under the section [Desktop Entry] you need to have Type=Service (NOT Application) and the line Actions=, where you have to specify the name or names of the action or actions of the service menu, each action being a separate section of this file with a separate name, of the form [Desktop Action name].

The Exec= line is to be set under each [Desktop Action name] section (NOT under [Desktop Entry]).

Here is an example with multiple actions.

[Desktop Entry]
Type=Service
Name=Download subtitles (filebot)
ServiceTypes=KonqPopupMenu/Plugin
Actions=en;fr;ro;it;
MimeType=video/*;inode/directory;
Icon=gnome-subtitles
Encoding=UTF-8
X-KDE-Priority=TopLevel
X-KDE-Submenu=Subtitles

[Desktop Action en]
Exec=filebot -get-subtitles -rename -non-strict %f
Icon=gnome-subtitles
Name=English (filebot)
Termial=true

[Desktop Action fr]
Exec=terminator -e "filebot -get-subtitles --lang fr -rename -non-strict %f" -p ttt
Icon=gnome-subtitles
Name=Français (filebot)

[Desktop Action ro]
Exec=terminator -e "filebot -get-subtitles --lang ro -rename -non-strict %f" -p ttt
Icon=gnome-subtitles
Name=Româneşte (filebot)

[Desktop Action it]
Exec=terminator -e "filebot -get-subtitles --lang it -rename -non-strict %f" -p ttt
Icon=gnome-subtitles
Name=Italiano (filebot)

which will give this for videos and directories:

enter image description here

You may have one or multiple actions.

Other settings under [Desktop Entry]:

X-KDE-Priority=TopLevel will show the action (or its group: see below) directly in the menu, like in the image above; without that, it will be under 'Actions' group.

X-KDE-Submenu=something will group under one menu-group called 'something' all the actions from files that have that line in them. (Even if the actions are in different service menu files, as discussed in this question; also see this question.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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