Open probonopd opened 3 years ago
In this code:
# code for NICENAMES mounting instead of the /dev/${DEV} default
if [ "${NICENAMES}" != YES ]
then
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
__log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'"
__remove_dir "${MNT_PREFIX}/${1}"
__log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed"
fi
You will have to put your message warning like that:
# code for NICENAMES mounting instead of the /dev/${DEV} default
if [ "${NICENAMES}" != YES ]
then
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
if [ ${?} -ne 0 ]
then
# COMMAND FOR YOUR UNSAFE UMOUNT MESSAGE
fi
__log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'"
__remove_dir "${MNT_PREFIX}/${1}"
__log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed"
fi
Hope that helps.
Thank you so much @vermaden, is is truly valuable!
Before I start patching your code locally, would you consider adding a configurable hook there, similar to the FM
hook for exo-open --launch FileManager
?
You mean something like that below?
With UNSAFE_UMOUNT_CMD for your command for warning?
# code for NICENAMES mounting instead of the /dev/${DEV} default
if [ "${NICENAMES}" != YES ]
then
umount -f "${MNT_PREFIX}/${1}" 1> /dev/null 2>&1
if [ ${?} -ne 0 ]
then
GROUP_USERS=$( pw group show ${MNT_GROUP} | sed -e 's|.*:||' -e 's|,| |g' )
for I in ${GROUP_USERS}
do
[ "${I}" = "root" ] && continue
DISPLAY_ID=$( procstat pargs $( pgrep Xorg ) | grep "^argv\[1\]:" | awk '{print $NF}' )
if [ -z "${DISPLAY_ID}" ]
then
continue
fi
__log "${DEV}: starting '${UNSAFE_UMOUNT}' command"
su -l "${I}" -c "env DISPLAY=${DISPLAY_ID} ${UNSAFE_UMOUNT_CMD} &" 1> /dev/null 2>&1
done
fi
__log "${DEV}: (direct) umount '${MNT_PREFIX}/${1}'"
__remove_dir "${MNT_PREFIX}/${1}"
__log "${DEV}: (direct) mount point '${MNT_PREFIX}/${1}' removed"
fi
Yes, UNSAFE_UMOUNT_CMD
. Maybe hand it over the geom, the mountpoint, and the nice name as args (in case the invoked command wants to show those to the user).
Hello @vermaden, do you have an idea how to be notified when a device was unplugged without being unmounted?
I would like to show users a message similar to this: