Created
March 5, 2011 18:36
-
-
Save geeknam/856589 to your computer and use it in GitHub Desktop.
Applescript to activate Internet Sharing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
register_growl() | |
growlnote("Copying process", "bootpd.plist copied") | |
do shell script "sudo cp /tmp/bootpd.plist /etc" password "yourpassword" with administrator privileges | |
tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing" | |
tell application "System Events" to tell process "System Preferences" | |
click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1 of window "Sharing" | |
delay 1 | |
if (exists sheet 1 of window "Sharing") then | |
click button "Start" of sheet 1 of window "Sharing" | |
end if | |
try | |
set message to "Internet Connection Sharing Enabled" | |
my growlnote("General Notification", message) | |
on error | |
set message to "Internet Connection Sharing was Not Enabled" | |
my growlnote("error notification", message) | |
end try | |
end tell | |
ignoring application responses | |
tell application "System Preferences" to quit | |
end ignoring | |
on register_growl() | |
try | |
tell application "GrowlHelperApp" | |
set the allNotificationsList to {"General Notification", "Debug Notification", "Error Notification"} | |
set the enabledNotificationsList to {"General Notification", "Debug Notification", "Error Notification"} | |
register as application "Enable Internet Connection Sharing" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Sharing" | |
end tell | |
end try | |
end register_growl | |
on growlnote(growltype, str) | |
try | |
tell application "GrowlHelperApp" | |
notify with name growltype title growltype description str application name "Enable Internet Connection Sharing" | |
end tell | |
end try | |
end growlnote |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment