Skip to content

Instantly share code, notes, and snippets.

@derrickj
Created February 1, 2012 20:59
Show Gist options
  • Save derrickj/1719289 to your computer and use it in GitHub Desktop.
Save derrickj/1719289 to your computer and use it in GitHub Desktop.
Quit torrenting when away from home
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>some-unique-label</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>path/to/quitTransmissionIfAwayFromHome.scpt</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
repeat -- loop forever, polling wifi connection
delay 20
set currentSSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --getinfo | grep ' SSID: ' | cut -c 18-"
if currentSSID is not "TheseAintTheSameKind" then
tell application "Transmission" to quit
end if
end repeat
@derrickj
Copy link
Author

  1. Edit the .scpt file to use your own WIFI name, and place it in ~/Library/Scripts/ folder.
  2. In the .plist file, change /path/to/quitTransmissionIfAwayFromHome.scpt to the location of where you put the .scpt file
  3. Place the .plist in ~/Library/LaunchAgents
  4. Run launchctl load </path/to/plist> or just restart your computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment