Add create shortcut option to context menu

I followed the steps below to add the option to create a shortcut to the context menu:

  • I created a file named create_symlink.desktop in the ~/.local/share/kio/servicemenus directory and wrote the following in it:

[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;application/octet-stream;
Actions=createSymlink;
Icon=insert-link

[Desktop Action createSymlink]
Name=Create Shortcut
Icon=insert-link
Exec=sh -c ‘for arg in “$@”; do ln -s “$arg” “${arg} - Shortcut”; done’ dummy %F

  • 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?