Changing the CPU priority of Mac OS X apps with ‘renice’

Mac’s Activity Monitor app is great, but there’s one thing it can’t do. As a long-time Windows user, I’m accustomed to tweaking the CPU priority on apps that are very CPU-intensive, e.g. compressing video, etc. On Mavericks I’ve noticed a couple of apps tend to slow my system right down (iTunes, Unarchiver, Google Drive), and wanted a quick way to get them under control. So I wrote this shell script.

#!/bin/bash
for APP in iTunes Unarchiver Drive ; do
  PID=`ps -Ac -o pid,command | grep ${APP}$ | awk '{print \$1}'`
  if [ -z $PID ] ; then
    echo \[$APP\] not running
  else
    echo \[$APP\] sudo 20 renice $PID
    sudo renice 20 $PID
  fi
done

Movie Review: The Hunger Games: Catching Fire

Unrequited infatuation, friendzoning, and romantic conflict permeates, giving the film an undertone of futility; a metaphor for the dystopic world of the Hunger Games series. Yes, the film has its Twilight moments. But redemption comes in the form of the smouldering uprising against the oppression of The Capitol alluded to in the film’s title. Overall, it’s impressive, however I left feeling like it wants so badly to make a commentary on the shallowness of present day media and society in general; but doesn’t quite make it. Like The Capitol is so ridiculous it’s almost satire. Maybe thats the point. ★★★★

How to shut down a Mac Mini server by pressing the power button

UPDATE: Initial tests see this script using 1-2% CPU however I haven’t noticed any lag on my (Plex) media centre, so you may want to use caution.

I’ve blogged before about how to shut down a Mac remotely using AppleScript, but this is near useless if, like me, you have a headless Mac Mini running as a media server and the reason you need to restart is that WiFi has dropped out.

There is no way to override what the power button does in OS X, however recently I came across a brilliant piece of AppleScript by MacRumours user Wondercrow which basically polls for the Shut Down dialog which appears when you press the button. Check it.

Read full post →

How to remotely shut down a Mac with AppleScript

Here’s a couple of simple AppleScripts to help you quickly shut down a Mac. This is handy if you are using it as a media center and want to shut down cleanly with one click, without picking up the keyboard or mouse, without logging in via Apple Remote Desktop, and without prompting for a password. I find a two-app approach works best as it gives you the flexibility to have a one-click dock icon on the target Mac as well as on the Mac you’re on, without too much redundancy.

Read full post →