diff --git a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident index 6641b72..19029cd 100755 --- a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident +++ b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident @@ -8,16 +8,15 @@ # CAVEATS: Assumes that the user homedir is always /usr/home/[username] # This will need to be fixed later # =============================== -ulist=$(users) -for dir in $(ls /usr/home) -do - echo "${ulist}" | grep -q "${dir}" - if [ $? -ne 0 ] ; then - #User not logged in any more - mount | grep -q "on /usr/home/${dir} type zfs" - if [ $? -eq 0 ] ; then - #Homedir is a still-mounted ZFS dataset - zfs unmount -f /usr/home/${dir} - fi - fi -done + +# Use last to get the last user logged in and grep for that users homedir pipe to text. +ulist=$(last | awk 'NR==1 {print $1}' | grep -f - /etc/passwd | cut -d":" -f6 | tee) + +if [ $? -ne '0' ] ; then + # Safety + exit +else + # No errors good. Finally unmount the dataset + umount -R ${ulist} + zfs unmount -f ${ulist} +fi