How to setup custom command to run it anytime for a selected file via GUI?


for example i want to run: recode ms-ee “pathtofile”
and i would like to execute this via gui without the need to open terminal and waste time copying, typing. Somehow for example Right click file / submenu / and “run recode” or something like that and it will run the custom command with custom parameters for the selected file.

Currently i am using XFCE and Dolphin file manager.


A couple of resources to consider

In case you want to experiment with other file managers


Thank you, so i setup new service file recode.desktop in $ find ~/ -type d -name ServiceMenus

[Desktop Entry]

[Desktop Action act]
Name=Recode to UTF-8
Exec=recode ms-ee %U

but it shows the right click menu item only when i click normal text file, not when i click file like:

$ file --mime-type ~/Downloads/*.srt
/home/me/Downloads/ text/plain

When i set the recode.desktop file to text/plain instead of text/* then it started showing the menu.
But the file is not recoded after i click the menu entry, like the command is not executed. So i am wondering how to debug this.
UPDATE: when i launch $ dolphin from command line, and right click the file, it add line:
Cannot initialize model with data QJsonObject() . missing: QJsonValue(string, “urls”)
when i click my custom menu entry it says:
/usr/bin/recode: Request `win-ee’ is erroneous

yes, in previous file version i have used erroneous parameter, but my current file has correct one: ms-ee
So do i have to restart something? I am launching Dolphin a new to test.


Exec = sh -c "recode ms-ee %U"

thank you all, @badbodh Your command may be useful for more complex commands as i read in tutorial. Thank you all for replies as it motivated me to find the solution. What helped to solve the issue is following workaround (other ways to solve are welcome if you share):

mv recode.desktop recode2.desktop
…exit dolphin…
mv recode2.desktop recode.desktop
set the exec line like this inside the file:
Exec=recode ms-ee “%U”
(the quotation marks was important as the file can contain spaces etc.)

and all works now. I am curious if i can group my custom actions into some sub menu now.
update, yes i just need to add new line below [Desktop Entry] line to the .desktop file:

X-KDE-Submenu=Menu name here
1 Like

I am just trying to add multiple actions under one menu or defining multiple menus in one .desktop file, but i am failing.

Anyone knows how to add second menu entry?
It does not matter much if the entry appears even for wrong (all) mimetype files.

i have tried many things but it either display nothing or only single entry.

I want to reencode file and my attempt was this command on Exec line:

ffmpeg -i “%U” -vcodec libx265 -crf 28 “%U_hevc_x265”

sidenote: i have found that possibly the icon names match file names in /usr/share/icons/Papirus/16x16/actions/