Skip to content
Swizec Teller - a geek with a hatswizec.com

Tweet a photo every time your mac wakes up with a simple hack

A few days ago there was a story on HackerNews about a guy who made a funky script to take a photo of himself every time he opened his computer. The original story was here.

Fdj3o
Swizec's ugly mug

I immediately liked the idea, but wanted to do something more with it. The only natural step was to take a photo and instead of storing it locally, just uploading it to some url and tweeting it. So last night I sat down for an hour of hacking and patched together a bunch of scripts and voila #TweetAWakeup was born.

You can view the photos live on twitter via the #TweetAWakeup hashtag.

If you want to make something like this, here's a quick howto of as many steps as I remember. I guess someone could make a simple script to do this, but then it would lose some of its geeky appeal.

Ok here's what you do:

  1. Register an app on Twitter.

  2. Get an imgur API key

  3. Install Sleepwatcher

  4. Install iSight CLI Image Capture

  5. Download and install twurl (you might have to update RubyGems with "gem update --system")

  6. Download my helper scripts

  7. Authorize twurl as per instructions on github (twurl authorize ...)

  8. run "sudo launchctl load -w /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist" (this makes sleepwatcher work)

  9. Edit ~/.wakeup and make it look something like this, obviously you should modify the path to suit your setup

  10. #!/bin/bash
    /bin/bash ~/Documents/random-coding/TweetAWakeup/TweetAWakeup.sh
  11. Go into TweetAWakeup/update.py and edit line 8 to match your imgur API key from step 2

  12. Go into TweetAWakeup/TweetAWakeup.sh and edit the paths to suit your setup

  13. You can change what the tweet will look like on line 6 ... would be nice if you leave the hashtag :)

  14. Run "twurl alias tweet /1/statuses/update.xml"

And you're done! Every time your mac wakes up from sleep it will take a photo with iSight, then wait 10 seconds and post it on twitter. The wait is there to give your computer supple time to connect to an internet.

Obviously this whole thing is rather pointless, but I find it interesting. Maybe something awesome falls out over time and I get a neato introspection into my daily life ... or better yet, a hawt sexy girl with no top will forget about this and accidentally post her boobies all over the internet then much funs will ensue.

PS: hopefully I didn't miss a step :)

Did you enjoy this article?

Published on January 14th, 2011 in Uncategorized

Learned something new?
Want to become a high value JavaScript expert?

Here's how it works 👇

Leave your email and I'll send you an Interactive Modern JavaScript Cheatsheet 📖right away. After that you'll get thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over my 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

Start with an interactive cheatsheet 📖

Then get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career.

"Man, love your simple writing! Yours is the only email I open from marketers and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"

~ Ashish Kumar

Join over 10,000 engineers just like you already improving their JS careers with my letters, workshops, courses, and talks. ✌️

Have a burning question that you think I can answer? I don't have all of the answers, but I have some! Hit me up on twitter or book a 30min ama for in-depth help.

Ready to Stop copy pasting D3 examples and create data visualizations of your own?  Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization

Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.

Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev

Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️