Automount on usage for bookmarks, soft links and .desktop links
In my experience very often a disk is not mounted, but some of its contents is pointed by
- bookmarks,
- soft links or
- URIs in .desktop files.
Now accessing such links results in errors:
Failed to open URI. Error when getting information for file "...": No such file or directory.
Then we need to close the error message, find the target disk, mount it, and only then repeat opening the link.
It would be more convenient if the disk could be mounted automatically when its file is requested (e.g. pointed by a clicked link).
The necessary disk usually can be found from the link (path). For example, my computer has:
/run/media/$USER/<disk label>
/mnt/<disk label>
(If necessary, the list of strings like these for a particular computer could be set in some settings).
Then a simple shell command could be used to check if a disk with such label exists, and then mount it, e.g. like this:
DISKDEV=$(lsblk -o LABEL,NAME | grep -e "^$DISKLABEL") && udisksctl mount -b /dev/sd${DISKDEV##*sd}
(Assuming that disk devices are /dev/sdX#
).