Put your Mac to sleep by sending a text message

Do you ever go out shopping, to the pub or to the beauty clinic for your fortnightly waxing session and forget to put your Mac to sleep? I know I do, so I thought of a way to do it by sending a text message from my mobile/cell phone - well, technically we’re not going to be sending a text (SMS) message, rather a multimedia (MMS) message.

I have my mobile phone contract with Vodafone and I can send an MMS message to an email address instead of a phone number and Vodafone converts the message to an email. If you’re unable to do this then I’m afraid you might as well stop reading here … :^(

For those of you still reading, you need to send an MMS message to your own email address and make a note of the email address it comes from - the ones I send from my phone are in the form 44xxxxxxxxxx@mms.vodafone.co.uk with the “xxxxxxxxxx” being replaced with my actual mobile phone number.

Now you need to download mac-help.com’s Sleep Automator action.

Next, open Automator and create a workflow by dragging the Pause action from the Automator library followed by the newly added Sleep from the System library:

Automator screenshot

(You’ll see why I’ve added the pause later on.)

Save this workflow as an application - I named mine “Mister Sandman” because I think I’m clever …

Now we need to write a small piece of AppleScript to launch this application, so launch Script Editor and enter the following command:

tell application "Mister Sandman" to run

Obviously you should replace “Mister Sandman” with the name you gave the workflow above. Save this script - I called mine “Launch Mister Sandman”

Open Mail, go to Mail -> Preferences -> Rules and select Add Rule. Fill in the conditions and commands as shown in this screenshot:

Mail rules

Obviously you can change Description to anything you like and you need to enter the email address you made a note of earlier in the From -> Is equal to field, select the AppleScript you saved in the Run AppleScript field and decide what word(s) you’d like to activate the process in the Message Content -> Contains field. Save the rule and you’re done.

I added Play Sound1 and Bounce Icon in Dock to the rule so that if someone else happens to be using my iMac when a ‘sleep’ email comes in then at least they know about it and have 30 seconds to cancel the workflow - that’s why I added the pause earlier on.

The success of this process relies on you having your Mac set to automatically check for emails periodically - if yours is set like this then, erm, good.

Update

As people have said in their comments you can use this procedure to get your Mac to do just about anything. For those of you who have questioned why I’ve set it up on my iMac: I’m a crip and if I’m in bed, for instance, it’s easier for me to send a text message than to spend the 20 minutes it takes me to get out of and then back into bed.

Notes

  1. When I selected Play Sound it showed Move Message but still allowed me to select a sound - this appears to be a visual bug in Mail itself. I edited the screenshot so as not to cause confusion incase your installation didn’t display the same bug.

60 comments so far

#1 SoulSniper said:

I WANT A MAC!

Posted 18 November ‘05

#2 Timmargh said:

Christ on a bike - you posted that quick!

Posted 18 November ‘05

#3 tugger said:

Awsome! keep them coming…!

Posted 19 November ‘05

#4 OvertoneBliss said:

Excellent, is their any chance you know of a similar piece of software that works for a PC?

Posted 19 November ‘05

#5 Timmargh said:

I don’t of anything off the top of my head, but I’m sure there will be add-ons for Thunderbird or Outlook Express to execute commands based on rules.

If I see anything I’ll let you know.

Posted 19 November ‘05

#6 J$ said:

with email spoofing being so easy, I’d imagine that this applescript could be a big security risk. Sure, its rather harmless putting the computer to sleep, but the annoyance factor of your box zonking out at random is a bit more troubling. Novel idea though, just don’t know how practicle. :)

Posted 23 November ‘05

#7 Anonymous said:

Whats your e-mail address??? 8p

Posted 23 November ‘05

#8 Jeff said:

Overtonebliss, yes there is software that can do this on a PC. Its called OSX86!

Posted 23 November ‘05

#9 WTL said:

It isn’t much of a security risk for the Mac. It gives you thirty seconds to abort it, and should someone figure out the message you send (it doesn’t have to be sleep), you can just change it.

I’m not sure who would even bother trying to spoof your email to put your system to sleep. Well, unless they wear a special person helmet, that is. ;-)

Posted 23 November ‘05

#10 Scott said:

Do you know of any applications (or widgets, preferably) that allow me to send a message to a UK mobile phone from my Mac? I currently only can find a US/Canada version.

Thanks.

Posted 23 November ‘05

#11 Barkie said:

For a Windows machine, you could probably create a VBscript to put the PC to sleep. I’m not sure whether you can create rules in Outlook (I don’t use it!). I use Lotus Notes - you can create rules in it, but not ones that control resources that are external to the app.

I wish I had Mac and OSX.
Microshaft sucks.

Posted 23 November ‘05

#12 Timmargh said:

J$: as WTL said I can just change the words needed to put my machine to sleep should anyone discover how to spoof my address. And on that point: I don’t go around handing out my mobile number while at the same time telling them that my Mac is set-up this way …

Thanks for commenting, though.

Posted 23 November ‘05

#13 Michael said:

Great! I’ll try it on my Mac at home! Thanks for the tip!

Posted 23 November ‘05

#14 Geisrud said:

In outlook 2003 you can create rules and have a script run. Not quite sure how to do it since I only use outlook at work and don’t have all the rights I believe I need.

Posted 23 November ‘05

#15 Tarous Zars said:

Cool Idea.
To make it work before Tiger, just make it all applescript. So instead of doing tell application “Mister Sandman” to run you can do tell application “finder” to sleep

Posted 23 November ‘05

#16 Anonymous said:

Any box that runs Outlook (03?) can do this. If you can shutdown a computer normaly, you can do it with outlook. Just set up a rule to run %systemroot%\system32\shutdown.exe then enter you favorite command-line arg. done.

Posted 23 November ‘05

#17 Timmargh said:

Nice one, Tarous. Trouble is that you don’t get the chance to cancel it if you’re using the computer at the time.

Posted 23 November ‘05

#18 Matt said:

Wow! Great! And you could probably do this to automate other things on your computer as well. Heck, even shut down, no?

Posted 23 November ‘05

#19 Greg Gauthier said:

Yes, you can do this with a PC. You’d have to write your own SMTP receiver that could run on your machine in the background, watching all the incoming email addresses, before they got to your mail client. You could do that with the plain-old GCC port for x86.

Then, you could hand off the content from anything received, to a PERL script, that could either do the work itself, or could invoke the GNU port for windows, which includes a shutdown command-line tool.

Of course, all of that would require the average user to have programming skills, and knowledge of the platform, so I guess the answer ultimately, is no.

Posted 23 November ‘05

#20 Peter said:

Not so. You can get a chance to cancel. Just use a display dialog with a timeout statement.

Posted 23 November ‘05

#21 BDC said:

Outlook 2003 can run an application based on a recieve rule, if i wanted to do this I’d combine it with a batch file running psshutdown ( http://www.sysinternals.com/Utilities/PsTools.html )

something like:
“c:\pstools\psshutdown -f -c -k -t 60” which is power off (-k) delay 60 seconds (-t 60) allow user to abort (-c) force applications to shutdown (-f).

BDC

Posted 24 November ‘05

#22 Anonymous said:

Nice. Now, how do you wake up a Mac remotely?

Posted 24 November ‘05

#23 anonymous said:

This is a brilliant little idea, obviously the implications are fantastic - why limit it to putting your mac to sleep?

Posted 24 November ‘05

#24 Anonymous said:

But what about security? You don’t want just anyone putting your mac to sleep; much less any of the other useful things one could do with this concept…

Posted 24 November ‘05

#25 Steve said:

I own and love the mac! Having said that the funniest part about this post is how many mac users assume that this is such a great example of stuff the mac can do better. This is just as easy or easier to do on a pc. No need to use scripting etc. Just build a rule in your favorite email program to execute the shutdown command with the sleep option.

Posted 24 November ‘05

#26 Timmargh said:

As many of you say: it’s not limited to putting your Mac to sleep - that’s simply the first thing I wanted to set-up.

As far as security goes: how can someone discover the trigger words you’ve set-up unless they can physically get to your Mac?

Posted 24 November ‘05

#27 Berislav said:

Very good hack. Pretty easy to create, but I never though of doing this.

Posted 24 November ‘05

#28 Aaron The Young said:

Uhm, why don’t you just remember to turn your Mac off before you leave? I don’t turn my Mac off ever actually…

Posted 24 November ‘05

#29 Robin Card said:

Yeah, it’d be easy to write something like this for Windows, in Visual Basic/RealBasic…

Posted 24 November ‘05

#30 Pipo said:

Yeah, you can do this on various flavors of Windows with Outlook and other clients. But do they lend themselves to this kind of amateur automatization?

Posted 24 November ‘05

#31 Anonymous said:


alert(“Mac - the best OS for idiots!”);

Posted 24 November ‘05

#32 Timmargh said:

Well, thanks you two. Did you read the site’s subtitle?

Either way, you can both fuck off.

Posted 24 November ‘05

#33 H. N. Teft said:

I am going to install this on my coworker’s macs as an April Fools joke, but maybe start playing with it earlier than April.

Thanks!

Posted 25 November ‘05

#34 Timmargh said:

:^D

Posted 25 November ‘05

#35 monkey_man said:

Yo Timmargh,

Very good thinking there, outside the box and stuff. Steve Hawkings better watch his back! (he looks like he’s always watching his back anyway with that twisted torso)

Posted 27 November ‘05

#36 Timmargh said:

Haha - you sicko.

Posted 27 November ‘05

#37 Anonymous said:

Very cool. I suppose there’s no way to do the reverse, to have the Mac wake based on an email? Thanks.

Posted 27 November ‘05

#38 Timmargh said:

That’s not possible unless Mail can check for new emails whilst the Mac is asleep … which it can’t.

I used to have a second landline purely for faxing to and from my Mac. I had the Mac set to wake up on an incoming call so I could just ring the fax line to wake my Mac - never actually used it though.

Posted 27 November ‘05

#39 LobsterMan said:

Cool!!! though I can care less if my mac is sleeping, and actually like it to be awake if it’s plugged in. but the idea is great for other remote actions, i’ll be sure to dig deeper into the idea. Thanks!

Posted 27 November ‘05

#40 Giuliano said:

A few comments:

1) Greg, that is not an SMTP receiver, the protocol is either IMAP or POP. Also, is not even a receiver, as the transactions are started from the client and not pushed from the server. Perhaps a sniffer, not an easy task though.

2) Timmargh, have you checked that the 44***@mms… address does not correspond to a real address? That poor man would otherwise receive lots of virus and spam on his email!

3) your idea is quite safe as you have three unknown variables, the sender, the receiver and the command.

4) it is “its content”, not “it’s content”. Now I am content…

Posted 29 November ‘05

#41 Timmargh said:

Well done, Giuliano, you spotted my, erm, deliberate mistake.

;^)

Posted 29 November ‘05

#42 Brad said:

Great idea! I set mine up to launch a few applications so they are ready when I get home.

Posted 2 December ‘05

#43 tugger said:

..could you arrange to change the trigger text via text message..?? :-)

Posted 8 December ‘05

#44 Brad said:

Hey, im trying to find the automator tool on mac-help but im having a helluva time. Will you e-mail me a direct link? Thanks.

Posted 26 December ‘05

#45 Brad said:

Nvm i got it, thanks aneways mate

Posted 26 December ‘05

#46 Timmargh said:

Righto..

Posted 26 December ‘05

#47 Laurent said:

I can do that cheaper. When my landline phone rings and the caller gets throught to voice mail, my ISP then sends me an email with the audio message as attachement, and of course the caller’s number…

Posted 28 December ‘05

#48 MHC said:

SPAM ALERT!!!!!!

Posted 20 January ‘06

#49 Timmargh said:

Spam? What spam?

*ahem*

Posted 20 January ‘06

#50 MHC said:

ROTFL

:^D

Posted 20 January ‘06

#51 Alan said:

Why not just set the computer to go to sleep after a period of inactivity? Easily done in the energy saver system preference! My computer atomaticaly sleeps after 30 mins.

Posted 31 March ‘06

#52 Timmargh said:

You can do that but I sometimes leave my iMac downloading something big or doing some other job and I don’t want it going to sleep halfway through.

Plus, being disabled, the more things I can do remotely the better.

Posted 31 March ‘06

#53 ts said:

for those interested in waking the machine: look up “wakeonlan” (network sys prefs has a checkbox).
Basically you need to get an awake machine on the SAME local network to send a special signal to your machine, and that’s it!

Posted 4 April ‘06

#54 Mikewake said:

First off thanks for the awesome tips on your site! When I put a folder onto the dock I can drag files directly to it, however I cannot drag “internet location files” (icon from the address bar) into there folders. I have to first open it up then drag and drop. Is there a way to fix that

Thanks

Posted 21 April ‘06

#55 Timmargh said:

" … When I put a folder onto the dock I can drag files directly to it, however I cannot drag “internet location files” (icon from the address bar) into there folders. I have to first open it up then drag and drop … "

You’re talking about the Get your morning news with Automator entry? I’ve had that trouble, too, but haven’t found a solution yet other than dropping it onto the desktop first and then dragging it to the folder in the dock.

Posted 21 April ‘06

#56 Benito said:

I just applied this to my Mail, along side the Act-On bundle. And I can’t get this rule to work. Nothing happens when I send an appropriate email. I tested the script and the Automator application separately.

When I right-click the email message and I choose “Apply Rules”, the Act-On bundle kicks in.

Any tips?

- Benito

Posted 12 March ‘07

#57 Timmargh said:

Benito: I’ve had a play with some settings but couldn’t get it to do what you’re describing. I couldn’t find any fixes online, either. Sorry!

Posted 14 March ‘07

#58 huladiday said:

Hello!
Nice site ;)
Bye

Posted 25 January ‘08

#59 chris said:

This is sweet, i dont use mail on my mac though. is there a way to do it using gmail

Posted 20 February ‘08

#60 Timmargh said:

I don’t use Gmail, Chris, so I’ve no idea I’m afraid.

Posted 20 February ‘08

Have your say

Feel free to express any opinion you like but please don't spam me - it's pointless and mildly annoying. Some HTML is allowed and paragraphs are formatted automatically - if you don't understand any of that then there's no need to panic: just write your comment and let me worry about it.

Remember Me?