Created
June 1, 2010 01:33
-
-
Save slambert/420455 to your computer and use it in GitHub Desktop.
applescript for scheduling selfcontrol - written by Karl James Pestka - see macosxhints artilce: http://www.macosxhints.com/article.php?story=20100801214648362
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
on run argv | |
set defaultTime to 1 | |
try | |
set myTime to item 1 of argv as number | |
on error | |
set myTime to defaultTime | |
end try | |
tell application "Usable Keychain Scripting" | |
tell current keychain | |
set myPass to (password of first generic item ¬ | |
whose name contains "SelfControl") | |
-- eliminate invisible characters, or "gremlins," from password | |
set x to quoted form of myPass | |
set myPass to do shell script "echo " & x & " | perl -pe 's/[^[:print:]]//g'" | |
end tell | |
end tell | |
tell application "SelfControl" to activate | |
tell application "System Events" | |
tell process "SelfControl" | |
tell slider of window "SelfControl" to set value to myTime | |
click button "Start" of window "SelfControl" | |
end tell | |
tell window 1 of process "SecurityAgent" | |
with timeout of 15 seconds | |
repeat | |
set tryAgain to false | |
try | |
set value of text field 2 of scroll area 1 of group 1 to myPass | |
on error | |
delay 1 | |
set tryAgain to true | |
end try | |
if not tryAgain then exit repeat | |
end repeat | |
click button 2 of group 2 | |
end timeout | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment