Skip to content

Instantly share code, notes, and snippets.

@skyriser
Last active August 29, 2015 14:00
Show Gist options
  • Save skyriser/11208385 to your computer and use it in GitHub Desktop.
Save skyriser/11208385 to your computer and use it in GitHub Desktop.
WD Mybook Block Sleep for Mac OS X

WD Mybook Block Sleep for Mac OS X 10.8

WD の Mybook っていう安い外部USBドライブが有るんですがそいつがしょっちゅうスリープしちゃうので、強制的に起こす奴。

Usage

# Place files in your home dir. (~/.scripts/***)
# Registration
launchctl load wd_block_sleep.plist
# Check
launchctl list -x | grep BlockSleep
<?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>info.levolution.wdBlockSleep</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/Users/USER/.scripts/wd_block_sleep.sh</string>
</array>
<key>StartInterval</key>
<integer>180</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
#!/bin/bash
volpresent=$(mount | grep VOLUME | wc -c)
if [ $volpresent -gt 0 ]
then
touch /Volumes/VOLUME/.blocksleep
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment