Last active
December 17, 2015 00:29
-
-
Save jjeaton/5521575 to your computer and use it in GitHub Desktop.
Wrapper Applescript for toggling Mark Jaquith's Localdev script: https://github.com/markjaquith/Localdev on and off. Can be used with FastScripts: http://www.red-sweater.com/fastscripts/ and set to a global keyboard shortcut. (I used Cmd+Shift+L). Also provides a growl notification of the updated status.
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
# Toggle Localdev On/Off | |
# Fetch the status of localdev | |
set localdevStatus to do shell script "/usr/local/bin/localdev status | awk '{print $3}'" | |
if localdevStatus is equal to "on" then | |
toggleLocaldev("off") | |
else | |
toggleLocaldev("on") | |
end if | |
on toggleLocaldev(value) | |
do shell script ("/usr/local/bin/localdev " & value) | |
tell application "System Events" | |
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 | |
end tell | |
if isRunning then | |
tell application id "com.Growl.GrowlHelperApp" | |
-- Make a list of all the notification types | |
-- that this script will ever send: | |
set the allNotificationsList to ¬ | |
{"Localdev Status"} | |
-- Make a list of the notifications | |
-- that will be enabled by default. | |
-- Those not enabled by default can be enabled later | |
-- in the 'Applications' tab of the growl prefpane. | |
set the enabledNotificationsList to ¬ | |
{"Localdev Status"} | |
-- Register our script with growl. | |
-- You can optionally (as here) set a default icon | |
-- for this script's notifications. | |
register as application ¬ | |
"Localdev" all notifications allNotificationsList ¬ | |
default notifications enabledNotificationsList ¬ | |
icon of application "Script Editor" | |
-- Send a Notification... | |
notify with name ¬ | |
"Localdev Status" title ¬ | |
"Localdev" description ¬ | |
"Localdev is " & value application name "Localdev" | |
end tell | |
end if | |
end toggleLocaldev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment