Created
April 16, 2014 19:19
-
-
Save hiilppp/10922752 to your computer and use it in GitHub Desktop.
AppleScript to lock your Mac's screen, pause iTunes (if playing), and sync OmniFocus (if open). (Use EventScripts to automatically trigger script when a Bluetooth device (e.g., your iPhone) leaves your Mac's range: http://www.mousedown.net/mouseware/EventScripts.html)
This file contains 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
do shell script "defaults write com.apple.screensaver askForPassword 1; defaults write com.apple.screensaver askForPasswordDelay 0" | |
repeat until (do shell script "defaults read com.apple.screensaver askForPassword") = "1" and (do shell script "defaults read com.apple.screensaver askForPasswordDelay") = "0" | |
delay 0.5 | |
end repeat | |
tell application "ScreenSaverEngine" to activate | |
if application "iTunes" is running then | |
tell application "iTunes" | |
if player state is playing then | |
set initial_sound_volume to the sound volume | |
set i to initial_sound_volume | |
repeat until i = 0 | |
set i to i - 1 | |
set sound volume to i | |
delay 0.1 | |
end repeat | |
pause | |
set sound volume to initial_sound_volume | |
end if | |
end tell | |
end if | |
if application "OmniFocus" is running then | |
tell first document of application "OmniFocus" | |
synchronize | |
(* | |
repeat until syncing is false | |
delay 0.1 | |
end repeat | |
do shell script "date \"+%-d.%-m.%Y, %-H:%M:%S\" > \"$HOME/Dropbox/var/lib/of/ls.txt\"" | |
*) | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cf. entering_range.scpt: https://gist.github.com/hiilppp/10922837