Skip to content

Instantly share code, notes, and snippets.

@ziggear
Created May 22, 2013 18:04
Show Gist options
  • Save ziggear/5629568 to your computer and use it in GitHub Desktop.
Save ziggear/5629568 to your computer and use it in GitHub Desktop.
#fw:http://www.macworld.com/article/1157370/applescriptsystempreferences.html
#AppleScript
#Filename: ToggleSharing.scpt
tell application "System Preferences"
activate
end tell
tell application "System Events"
tell process "System Preferences"
click menu item "Sharing" of menu "View" of menu bar 1
delay 2
tell window "Sharing"
click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
delay 1
if (exists sheet 1) then
if (exists button "Turn AirPort On" of sheet 1) then
click button "Turn AirPort On" of sheet 1
delay 1
end if
click button "Start" of sheet 1
end if
end tell
end tell
end tell
tell application "System Preferences"
quit
end tell
#bash script
osascript ToggleSharing.scpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment