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

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 →

Sync podcasts to your iPhone without using Apple’s Podcasts app

If you’re anything like me and you are an Australian with an iPhone, you are probably stuck on Telstra’s 3G network. Thus, you would be blessed with a pittance of 3G data quota each month. Recently, something has been repeatedly slurping up multiple 120 MB downloads over 3G, suspiciously similar in size to Above & Beyond’s Group Therapy podcast (which is awesome by the way).

I stopped using the Podcasts app but my data usage was still up the shit. I’m basically convinced it’s still streaming episodes I’ve already downloaded — despite me turning off every conceivable option in the iPhone settings related to this. So I deleted it but I can’t live without my trance :(

Why can’t things just go back to the way they were? I should be able to just download the podcast files via iTunes and then sync them to my phone — it should be that simple. There is no need for another app, and the App Store reviews reflect this. Fortunately, I found a simple and ingenious solution which completely removes your dependence on Apple’s crappy app allowing you to claim back your 3G data usage.

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 →