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

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]
Name=Download subtitles (filebot)

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

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

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

[Desktop Action it]
Exec=terminator -e "filebot -get-subtitles --lang it -rename -non-strict %f" -p ttt
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.