Archive for the ‘automator’ Category

Sometimes I’ve got a nice big long article I want to read and have to shoot out of the door, effectively not giving me time to actually read it. Sometimes I save it for later by marking it up in my del.icio.us bookmarks, but if it’s something I really want to read, I’ll use this handy little Automator workflow to save it out:

I set the ‘Text to Audio’ action to ‘Show action when run’ using the expansion arrow:

This way you can set the file name of the resulting audio to something sensible, rather than have it set to the same thing every time – the file name will appear as the track’s title in iTunes.

All you have to do now is copy whatever you want into a blank TextEdit document and run this workflow – you don’t even have to save the document, Automator can pick it up regardless. The computer voice my trip over some words, particularly some non-english words. But it’s easy to comprehend.

You can set the rate in the System Preferences ‘speech’ preference pane:

I set the Genre to ‘Podcast’ to take advantage of iTunes’ smart playlisting – I have an ‘Unplayed Podcast’ smart playlist with any podcasts with a play count less than 1. That way I can find it easily on my iPod.

There are a bunch of apps out there – some free and some shareware – that allow you to use your mac as an alarm clock. They’re mostly pretty good too, but I like the customizability of an Automator based solution, and I think you will too – with a little drag and drop you can have a very complex little morning radio bit.

The Basic iTunes Alarm

You can make a very simple little alarm with just three actions:

Set Computer Volume (turn the volume up to maximum in case you muted it the previous day)

Get Specified iTunes items (select the playlist you want to play in the morning)

Play iTunes playlist

Here’s a screencap of what the finished article should look like:

Next, save it and select ‘Save As Plugin’ from the menu, and choose an iCal plugin. Automator will spit out an action into iCal, which you can move around to the proper date and time and also set repeats.

Now, iCal alarms will wake your mac from sleep but not from a shut down state (which is just as well, really). If you shut down your mac every night, you’ll need to set up a little scheduling. Fortunately this is simplicity itself from the Energy Saver preference pane. Open up System Preferences and click ‘Schedule’:

Then put in the time you want your mac to wake. It can be at the same time or a little after – the mac will run as soon as it wakes up.

You’ll also need to set auto-login:

I’ve blurred out the accounts and account names because I’m incredibly paranoid. So don’t worry about that blocky effect.

Also, a brief warning: this is a security risk, so I’d set it back to a proper login if you ever leave your machine unattended where someone might faff around with it.

Once all that’s done, you should have a simple little Automator alarm clock that you didn’t have to pay for or anything. Wohoo! But of course plenty of freeware will do this, so what’s the real advantage? Customizability!

Advanced stuff

You can drop other actions in teh bottom of the queue easily. My personal favourite, though, is having a little built-in DJ.

The iTunes volume actions will turn the music down to let the speech server talk over the music, but you can use the system volume options to really blare out the voice if you want. I don’t, because my Macbook’s tawdry built-in speakers simple don’t allow it – maximum volume is about right for music.

Beyond that, you can add more complex speech: for example, here’s a little Applescript that’ll interface with the rather fine (and also free) ?TextWrangler:

tell application “TextWrangler”
open “path/to/file.txt”
set readOut to line (random number from 1 to 22) of document 1 as string
end tell

say “Today's usage rule is: ” & (usageRule)
Using Automator’s ‘Run Applescript’ function you can get this script to read random lines from a text file (mine contains the usage rules from Strunk and White, which I laboriously typed out). To double check the line numbers in TextWrangler, just use the ‘Add/Remove Line numbers’ function in the ‘Text’ menu

Other stuff

Using my previous hint to set display sleep times, you can make sure the screen isn’t blaring away (although personally I’ve found the bright screen useful in dark mornings).

The Preamble

So I’ve been using a song tagging system based on ratings for a while now, (more on that here), but I’ve recently started using a different system to add more granularity to my tagging – for example, tagging my ‘Inspirational’ (2 star) list to separate the up-tempo numbers good for writing action from the stately pieces for description and the sad pieces for… well, sad stuff.

I’d long decided to use the ‘Grouping’ section in iTunes to do this, but tabbing over to iTunes and getting info on the playing song and then typing in the tag seemed like too much hassle – I don’t want to leave what I’m doing for very long. Enter Automator and Quicksilver…

The Instruction

First off, you’ll need Doug’s Automator Actions for iTunes, available here. Install them if you haven’t got them already, because there’s some amazing stuff in there.

Next, put together a simple two-step workflow: ‘Get the Current Song’ followed by ‘Set Info of iTunes Songs’.

Then, and this is important, click the ‘Grouping’ checkbox and under ‘options’ click the ‘Show Action When Run’ checkbox. This means that, when the workflow runs, it’ll pop up a miniature version of iTunes’ option box with grouping already selected and the cursor set to a-blinkin’. This is awesome.

Stick the resulting workflow in a place where Quicksilver can see it. Assign a trigger (if you’re not familiar with these, Merlin’s got a great post about them or just a simple abbreviation.

Now, whenever you hear a song that fits a particular mood or tag, open up the workflow from QS and type your tag, then get back to your stuffs. Fantastic, and probably more useful to most people than ratings-tagging. (Although I still like that for being able to sort my music solely on my iPod).

I like all-in-one Macs. Currently I have a Macbook, before that I had one of the old CRT eMacs. The all-in-one design minimizes clutter and cable mess. There’s a tradeoff in a lack of upgradability and maintenance, but I feel the pros outnumber the cons.

Anyway, these macs are all missing one feature that, for me, is rather important: a power button.

If I’m doing a batch-processing task, or downloading an especially large file, I like to be able to switch off the display on my Macbook to avoid power costs – that display is the really power-hungry part of the computer. The only easy way to do this with an all-in-one is to open system preferences, go to energy saver, and drag that little slider all the way to the left.

That’s okay, but I’d prefer a keystroke, thankyou-very-much.

There are Applescript solutions available, but they involve playing around with the pmset command line utility, which requires sudo access to alter, so you have to play around with sudoers and whatnot. I’d rather avoid that if I can.

Instead, I’ve found a ginchy way to do this with Automator.

The Fix
So to fix this I’ve found a neat little Automator action that you can download and install yourself. You can get it here as well as lots of other handy-dandy Automator doodads.

What this action does is give you a slimmed down version of the energy saver right there in the Automator window. Here’s a pic to illustrate:

Now all you have to do is make up a simple one-action workflow and attach it to a keybinding. Bam! Display on/off switch. Well, sorta – it turns off after a minute. But it’s the closest thing you can get.

You can also use this action in a bunch of other workflows – I use it in my alarm clock script to ensure that the display turns off while the musics are waking me up. Hallelujah!