Then I ran the following code: chmod +x ~/.local/share/kio/servicemenus/create_symlink.desktop
With this option, when I right click on any file and click Create Shortcut, it creates a shortcut of that file in the same folder, but I have a problem.In Dolphin, when I right-click without selecting any file or folder, this “Create Shortcut” option appears again and when I click it, it creates an irrelevant shortcut to a parent folder. How do I make this “Create Shortcut” option appear only when I right click on a file or folder?
here is a primer on service menus in case you haven’t seen it yet.
if your question is how to control when the service menu appears in the context menu choices, that is all down to the MimeType… if it matches, the service menu appears.
here is a list of mime types you can use to distinguish between file types
Well, your mimetype includes directory, hence the popup. Regardless if you set the priority to toplevel or not.
If I may add, you might wanna use a kdialog to have the link wherever you want it to be, maybe as a menu option.
I think what I want goes against the nature of the mimetype. Actually, this is not a very important issue, but I just asked because I was curious. I just want the “Make a Shortcut” option to appear if I select a file and right click on it, but it shows “Make a Shortcut” even if I click on an empty place.
I’ll try to make a video : streamable . com/6l57cp
You have direction as mimetype. Making it not appear on an “empty” space in a directory is not possible. Not that I’m aware of that is. So…grain of salt and all that.