Force quit app, send SMS and email notification

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

I have a pesky app that keeps hanging on my Mac (it's not fully Mavericks ready). However, when it does run, it's awesome, so I created a Hazel workflow that will restart it, and then send me alerts to confirm.
To kick off the workflow, I'm using a Launch Center Pro custom URL to create the text file in a special dropbox folder that Hazel watches, but you can use just about any app to do that piece. Here's the gory details:

Here’s the high level workflow: Created custom action on Launch Center Pro that auto-creates a text file in a special dropbox folder that hazel is watching.
When hazel sees the file, it runs 3 apple scripts - 1) force quit the app, wait a couple seconds, then launch it again, 2) send me an SMS notification that my Blinq service was restarted, and 3) send me an email saying the same.

Launch Center Pro custom URL that writes a simple text file to my dropbox folder.
For my example, I’m creating a file called “Reset Blinq Now” with the text “Reset” in my dropbox folder “Blinq Reset Folder"
launch://dropbox/new?name=Reset%20Blinq%20Now&text=Reset&path=%2FBlinq%20Reset%20Folder

Applescripts used in Hazel

1) Force quit the application “Blinq” on my Mac, wait 5 seconds, then re-launch.

do shell script "killall Blinq"
delay 5
tell application "Blinq" to launch

2) Send an SMS alert. Note: for this part to work, messages has to be running, so I put a launch command in just in case. Also, whoever you send it to has to be your messages “buddy” list.

tell application "Messages" to launch
delay 5
tell application "Messages"
send “SMS Message Text" to buddy “XXX-XXX-XXXX" of service “E:XXXXX@gmail.com"
end tell

3) Send an email alert.

tell application "Mail" to launch
delay 5
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"Blinq Photo Service has been reset", content:"The Blinq Photo Service has been reset on the Mac Mini in the living room :-)", visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties {address:”XXXXX@gmail.com"}
send
end tell
end tell
xrocks
 
Posts: 1
Joined: Thu Feb 27, 2014 5:23 pm

whats your rule that allows hazel to "see" that said application is hanging?
elgallo
 
Posts: 17
Joined: Sat Apr 19, 2014 7:41 am


Return to Tips & Tricks - DO NOT POST QUESTIONS