Unable to add Dolphin context menu action for sidebar (Places/Devices)

Bit of a weird edge case here - I’m working with a non-root encrypted drive and using Dolphin to unlock/mount/unmount it works perfectly, but I’m trying to add a context menu action to lock it again. The use case I’m aiming for is unlocking the drive, editing, then locking it again; right now, I’ve made a .desktop service file that properly unmounts and locks the drive but it only appears in the main file window, rather than on the devices themselves. I can use it by navigating to the mountpoint in the main Dolphin window, then right clicking the folder there - what I’m aiming for is to be able to use it by right clicking the device in the Devices section. For reference, here’s the .desktop file:

[Desktop Entry]
Type=Service
X-KDE-Priority=TopLevel
MimeType=inode/directory;
Actions=lock;

[Desktop Action lock]
Name=Lock Drive
Icon=lock                   
Exec=TDEV=`df %u | grep -Eo '^[/a-z0-9]*'` && RDEV=`realpath --relative-to /dev $TDEV` && udisksctl unmount -b $TDEV && udisksctl lock -b /dev/`ls /sys/block/$RDEV/slaves`

My initial thought was that I just had the wrong MimeType, and needed inode/blockdevice or inode/mount-point or something. Unfortunately neither work - they’re ignored even in the main Dolphin window where inode/directory works (on folders that are mountpoints). I’ve read through all the documentation I can find, searched the web and this forum, and tried to use github’s (terrible) search in the Dolphin source code with no luck. Any chance someone here could give me a tip about how to add to Dolphin’s context menu in the side panel specifically?

The placement panel code is part of kio framework code. It does not implement integration with Services Menu on purpose.

Your use-case should be covered though, unlocking/locking crypted drives is supported natively using udisks.

1 Like

thanks for the response, and sorry I missed it for so long lol. I’m glad to hear that at least I wasn’t just missing something in the documentation - but just to be clear, when you say supported natively you mean by udisks through the console, not by dolphin, right? I’m comfortable doing it with udisks and/or cryptsetup, I just think it’d be nice to have the option through the GUI as well and it’s been a fun learning experience trying to add it.

nevermind, I’ve reinstalled Arch since and testing it again on a fresh install the ‘unmount’ option on the block device in dolphin also locks the drive now. thanks again!