KDE Device Notifier work-around

KDE Device Notifier can be annoying sometimes. The problem is that clicking on the Eject icon in Device Notifier (tooltip ‘Click to safely remove this device’) both unmounts and ejects the device (two separate commands). Of course, in the case of a USB device the device remains physically connected until you pull out the USB plug. You cannot re-mount the device in KDE Device Notifier until you unplug it and plug it in again. However, there is a hack that can help somewhat, as I explain below.

Firstly, note that it is possible to mount and unmount drives by using the ‘udisksctl’ command. For example, consider one of my USB HDDs which has the label ‘USBHDD01’ (I assign a label to all HDD partitions, be they on internal HDDs or on external HDDs/pendrives). It is possible to unmount the specific USB device and remount it by using the following commands:

fitzcarraldo@clevow230ss ~ $ udisksctl unmount -b /dev/disk/by-label/USBHDD01
Unmounted /dev/sdb1.
fitzcarraldo@clevow230ss ~ $ udisksctl mount -b /dev/disk/by-label/USBHDD01
Mounted /dev/sdb1 at /run/media/fitzcarraldo/USBHDD01.

In both the above cases the USB device remains visible in Device Notifier. I have created a couple of executable Desktop Configuration Files in the directory ~/Desktop/ which I can double-click to run each of the above commands. I have given each of them an appropriate icon:

The file ~/Desktop/Mount_USBHDD01.desktop contains the following:

[Desktop Entry]
Comment[en_GB]=Mount USB HDD with label USBHDD01
Comment=Mount USB HDD with label USBHDD01
Exec=udisksctl mount -b /dev/disk/by-label/USBHDD01
GenericName[en_GB]=Mount_USBHDD01
GenericName=Mount_USBHDD01
Icon=media-mount
MimeType=
Name[en_GB]=Mount_USBHDD01
Name=Mount_USBHDD01
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

The file ~/Desktop/Unmount_USBHDD01.desktop contains the following:

[Desktop Entry]
Comment[en_GB]=Unmount USB HDD with label USBHDD01
Comment=Unmount USB HDD with label USBHDD01
Exec=udisksctl unmount -b /dev/disk/by-label/USBHDD01
GenericName[en_GB]=Unmount_USBHDD01
GenericName=Unmount_USBHDD01
Icon=media-eject
MimeType=
Name[en_GB]=Unmount_USBHDD01
Name=Unmount_USBHDD01
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

(N.B. Since I could not find a media-unmount icon, I have used the media-eject icon to represent Unmount.)

This is not perfect in the sense that the device will still disappear from Device Notifier if you click on the Eject icon in Device Notifier. But at least I can avoid doing that until I really do want to unplug the device from my laptop. In other cases I simply double-click on the Mount_USBHDD01 icon and Unmount_USBHDD01 icon on my Desktop to mount and unmount the USB device as many times as I need to.