Thursday, August 22, 2013

Mac idle flash killer

ss_cg.pngMy kids are always playing flash games on our Mac. I have nothing against flash games, of course, but when the kids want to do something else, they always go, leaving the game running on the computer.

Flash is a processor-hog, which means my computer works like crazy to keep up with it all (especially if they leave 8 tabs of Barbie karaoke going), which means the computer gets really hot and I'm sure runs like that for hours, which can't be good for it...

So -- a solution!

ss_cg2.pngI've written a small perl script that checks to see if the Mac's been idle more than 10 minutes, and if so, kills all flash processes owned by the current user. Firefox then shows a message where the flash process was that the flash process crashed and you can reload it any time.

Then I set up a launchd ("launch daemon") process to run my script every 10 minutes. So those processes will now run at most 20 minutes unattended before the script kills them.

Interested?

Only do this if you trust me and accept that there's no guarantee of anything. And if anyone you don't trust asks you to download files and install them on your machine like this, don't do it.

Okay, that all said, here are the two files you need.

Setup:

  1. Unzip those two files to your desktop.
  2. Open Terminal (Finder: Go -> Utilities, Terminal)
  3. Copy/paste this command into the terminal, and press enter:

    mv ~/Desktop/killFlashIfIdle.plist ~/Library/LaunchAgents; chmod a+x ~/Desktop/killFlashIfIdle; sudo mv ~/Desktop/killFlashIfIdle /usr/local/bin/ ; launchctl load ~/Library/LaunchAgents/killFlashIfIdle.plist; launchctl start local.killFlashIfIdle

  4. Enter your password when it asks for it.
You'll know it's working if you open a flash site, then leave the computer untouched for 20 minutes -- it should kill it.

The scripts are so tiny you can round their sizes down to zero. The commands they issue are super simple (ps, perl, and ioreg), so the odds of anything awful happening are miniscule. Still, if for some reason you want to uninstall the scripts, here's how you do it:

Uninstall:

  1. Open Terminal (Finder: Go -> Utilities, Terminal)
  2. Copy/paste this command into the terminal, and press enter:

    launchctl unload ~/Library/LaunchAgents/killFlashIfIdle.plist; rm ~/Library/LaunchAgents/killFlashIfIdle.plist; sudo rm /usr/local/bin/killFlashIfIdle

  3. Enter your password when it asks for it.
Enjoy.

Sunday, August 18, 2013

Ashton Kutcher's advice for young people

... is surprisingly wise:



His "smart is sexy" comment probably rang an odd chord with some of the youth, probably because that's not the experience most of us have -- at least the way we usually define "smart".

I'm guessing he meant something more like "confident", but thankfully the best kind of confidence comes from wisdom, which comes from knowledge paired with experience, so "smart" is a good word for this audience.

Nice job, Chris.

Does anyone read this thing?

views since Feb. 9, 2008