Skip to content

Instantly share code, notes, and snippets.

@rshev
Created October 5, 2015 15:12
Show Gist options
  • Save rshev/f67635afd98c01f12322 to your computer and use it in GitHub Desktop.
Save rshev/f67635afd98c01f12322 to your computer and use it in GitHub Desktop.
Sleep and remount scripts for use with SD cards on MBPr
#!/bin/sh
volumeName="sdextend"
volume=`mount | grep "$volumeName" | sed 's/.*\(disk[0-9]s.\).*/\1/'`
if [ -n "$volume" ]; then
# force quit apps here
/usr/sbin/diskutil unmount force $volume
/usr/sbin/diskutil eject $volume
fi
sudo kextunload -b com.apple.driver.AppleUSBCardReader
exit 0
#!/bin/sh
volumeName="sdextend"
function check()
{
var=`mount | grep "$volumeName"`
if [ -n "$var" ]; then
#open /Applications/Dropbox.app
exit 0
fi
}
sleep 5
check
var=""
i=0
while [ $i -lt 10 ] && [ -z "$var" ]
do
sudo kextunload -b com.apple.driver.AppleUSBCardReader
sudo kextunload -b com.apple.driver.AppleUSBStorageCoexistentDriver
sudo kextunload -b com.apple.iokit.IOUSBMassStorageDriver
sudo kextload -b com.apple.iokit.IOUSBMassStorageDriver
sudo kextload -b com.apple.driver.AppleUSBStorageCoexistentDriver
sudo kextload -b com.apple.driver.AppleUSBCardReader
sleep 5
check
i=$[$i+1]
done
osascript -e 'display notification "Re-mounting SD Card failed 10 times" with title "Wakeup script"'
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment