Automatic Mount Monitor script for macOS

os:mac

#1

Hope this helps someone: I have an issue where Cryptomator sometimes dismounts so I wrote an Applescript to warn me via a Pop-up window which I can’t miss if the drive is not mounted.

I run the script automatically every 1 minute using a custom macOS launchd agent like this:

Open Apple’s editior in “/Applications/Utilities/Script Editor.app”

Copy and paste the below script and save it someplace naming it: “cryptomatorMountChecker.scpt”

Remember the path.

# set diskName to the Cryptomator mounted volume (/Volumes/<mountpoint>) you'd like to monitor
set diskName to "_cryptomator"

tell application "System Events" to set diskNames to name of every disk

if diskName is in diskNames then
	#display dialog quoted form of diskName & " is already mounted." & return buttons {"OK"} default button 1
else
	#do shell script "open /Applications/Cryptomator.app"
	display dialog quoted form of diskName & " is no longer mounted!" & return buttons {"OK"} default button 1
	
end if

Then create a Launchd Agent like so:

cd ~/Library/LaunchAgents/

vi cryptomator.mount.monitor.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>Cryptomator Volume Mount Monitor</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/osascript</string>
        <string>/Users/<username>/cryptomatorMountChecker.scpt</string>
    </array>
    <key>StartInterval</key>
    <integer>60</integer>
</dict>
</plist>

Save the file and now from Terminal run:

launchctl load ~/Library/LaunchAgents/cryptomator.mount.monitor.plist
launchctl start cryptomator.mount.monitor

You’re all set. Eject the drive in Cryptomator, wait 1 minute and you should see a pop-up informing you. Mount the drive once more and no popups.

Enjoy.


#2

That’s quite a creative approach, thanks for sharing. :slight_smile: Just wanted to let you know that the disappearing volume is a WebDAV bug in Finder of macOS High Sierra. It has been fixed by Apple in macOS Mojave. Another “fix” will be the FUSE integration of Cryptomator 1.4.0 that’s currently being worked on. You can get a sneak peek by downloading Cryptomator 1.4.0-beta3 but be aware that it’s not a stable release yet.


Find mount point of revealed vault using FUSE in Terminal on macOS High Sierra
#3

Thanks. I ran with your sugestions with the beta verson and FUSE for Mac successfully and upgraded happily to Cryptomator 1.4.0 since its release with no errors.

VIM is able to create its .<filename>.swp files without error.

One thing I have noticed though - markdown editors such as Typora.io & iA Writer state early on that the file system cannot support their builtin version history support. Not sure how they achieve this but is this limitation imposed by the FUSE file system perhaps?