Entries filed under OS X

Using EZCap EzTV668 DVB+ receiver for SDR on Mac OS X 10.7

There has quite a bit of buzz about the RTL-SDR project that is going on over at reddit on the rtl-sdr subreddit. Most of it has been about using the RTL2832/e4000 devices under Windows and Linux. Since I primarily use Mac OS I decided to cobble together the various hints of other people who have successfully used the devices on Mac OS and document them in a gist on github:


Update: After some feedback on reddit for the previous gist I decided to revisit my build to that I would have a more up to date version of GNURadio. After much hacking I came up with these directions for getting GNURadio 3.6.0 working on 10.7:


After following those directions you’ll want to then install the rtl-sdr driver and then gr-osmocomm so that you’ll be able to use the RTL tuner with gnuradio.

Permanently prevent OS X Mail from inserting attachments at the end of emails

OS X Mail defaults to including all attachments at the end of emails.  While useful for some file types (ZIP archives, programs, etc.), I still prefer that images be embedded exactly where I paste them in a message.

This insert-at-the-end behaviour can be disabled by unchecking an option in the Edit/Attachments menu:

Unfortunately, the option always reverts to being checked again for subsequent emails, with no obvious way to disable this behaviour permanently.  As it turns out, the solution is simple:

If you disable this option while editing an email, it will remain disabled for that message only. If you disable this option from the main window, it will remain disabled for all future messages.

Tangentially, the option to “Send Windows-Friendly Attachments” can only be toggled when you are not editing an email.  When you have a message screen open, the option is greyed out.

These options seem like perfect candidates for Mail’s Preferences menu.  Why they exist solely as menu options and why they behave this way remains a mystery to me.

Changing nginx’s worker process user on OS X

nginx defaults to running its master process as root and all workers as nobody.

You can tell nginx to run worker processes under different credentials by setting the user directive in nginx.conf.

On OS X, you need to specify a valid group as well, since nginx will default to looking for a group that doesn’t exist. You will see “nginx – getgrnam()” in the error log when this happens. The easiest solution I found is to assign the OS X staff group:

user userid staff

It probably bears mentioning that changing the runtime credentials won’t negate the need for sudo if you run your web server on port 80, since OS X (and all Unixes) will not allow nginx to use that port unless it runs as root.

Group similar apps in OS X dock with spacer tiles

OS X’s dock allows the addition of spacer tiles, blank objects that occupy the same space as an application icon.  Spacer tiles are quite helpful for organising applications into logical groups.

Adding spacer tiles is relatively simple:

  1. Launch Terminal (from Applications/Utilities).
  2. Cut and paste the following into the command line, once for each tile you want to add.  (Need 4 tiles?  Run it 4x.)
    defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
  3. Restart the dock:
    killall Dock

Spacer tiles behave like normal application icons: they can be dragged into any position, or dragged out of the dock completely to remove them.

Quitting Terminal app in Lion when the last console session ends

Lion’s Terminal app and its tabbed full-screen mode is a huge improvement for me. One thing that became a minor annoyance, however, is Terminal’s failure to quit when the last console session ends: Cmd-Q is still required to quit the app completely.

The workaround I chose takes advantage of existing muscle memory.  I had already configured an alias for exit, allowing me to type x to end a console session.

To solve the Terminal app problem, I repurposed x as a function in my ~/.bash_profile:
function x {
[ "$(w -h | grep "^$(whoami) *s[^ ]* *-"|wc -l)" -le 1 ] && osascript -e 'tell application "Terminal" to quit' || exit

The function checks for the number of active console sessions. When x is called and only one session remains, osascript is invoked to quit the Terminal app completely.

Access OS X clipboard from CLI

Accessing the OS X clipboard (or “pasteboard”) from the CLI is made simple with the pbcopy and pbpaste commands:

cat ~/ confidential_information.txt | pbcopy
pbpaste > confidential_information.txt

The pbcopy/pbpaste manpages have more detailed information about their use.

An interesting footnote to OS X’s clipboard system is that there are actually four pasteboards, each assigned to its own, unique purpose. The Find clipboard is particularly useful because it enables search queries to be saved automatically between applications. To test this, enter a string in (for example) Firefox’s search box. Don’t copy it to the clipboard. Now open your text editor and start a new search. The same string should already be in the dialog box…

Permanently disable Google Software Update on OS X


Parsa Fatehi kindly points out below that Google now has a simpler solution:

As many have noted, recent Google software releases for OS X now include Google Software Update, a background daemon that checks for and installs updates to Google software with no user intervention and no option for disabling it.

In theory, GSU is removed automatically when the last Google software to utilise it is uninstalled from your computer… but this assumes that you use the uninstallers bundled by Google, and don’t attempt to remove the software by hand.

I’ll save my disappointment for another editorial.
Instead, here is a workaround:
sudo rm /Library/LaunchAgents/com.google.keystone.agent.plist
sudo rm /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo rm /Library/LaunchDaemons/com.google.keystone.daemon4.plist

sudo touch /Library/LaunchAgents/com.google.keystone.agent.plist
sudo touch /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo touch /Library/LaunchDaemons/com.google.keystone.daemon4.plist

sudo chmod 000 /Library/LaunchAgents/com.google.keystone.agent.plist
sudo chmod 000 /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo chmod 000 /Library/LaunchDaemons/com.google.keystone.daemon4.plist

This hint does not uninstall GSU – it only “disables” the launchd entries that would run GoogleSoftwareUpdateAgent.app at boot time.

We first remove each entry (sudo rm …) and create empty files (sudo touch …) in their place.  We then change their POSIX permissions (sudo chmod) to deny any access to these files (000) for all accounts except root.

Creating inaccessible dummy files is important.  Without them, the launchd entries can simply be replaced whenever Google software is run.  But with these steps taken, no Google app can reinstall the GSU launchd entries, unless they:

  • ask for your username and password (to authenticate as root),
  • use different filenames, or
  • create local launchd entries (~/Library/Launch[…])

This hint is easily adapted for each of these cases. You can also use this technique to remove GSU completely.

Enable local search on Leopard Server

By default, Leopard Server disables Spotlight indexing on its system drive.

I assume that this decision was made to avoid confusion when administrators search the global catalog for system files on other machines. However, I find this to be a hassle when I need to locate a file on the server itself.

You can easily include a server’s local drives in its Spotlight index using mdutil:

sudo mdutil -i on /

The same command can be reissued with the off parameter to reverse the change.

Streaming your iTunes library, improved

The recent post on TUAW about streaming your iTunes library over the internet inspired me to stop using SimplifyMedia and to roll my own solution. The downside was that I found that the software TUAW linked to did not consistantly work. Worse was that the Mac specific version of the application did not work on Leopard.

I compiled a fresh version of the application that works on Leopard. Its much nicer than the generic Java version. When you run it you’ll notice a new icon in your menu bar.

Click on it and you will be able to set up the hosts as they describe in the directions at TUAW.

Download RendezvousProxy for Mac.

Using mdfind to preview all tracks by an artist

Two among OS X’s more underutilised CLI tools are mdls and mdfind.

These both query the detailed metadata in Spotlight’s database (hence the md prefix).  The first command will return all the attributes of a file or directory.  The second will find all files that match a given attribute query string.  O’Reilly’s MacDevCenter has an article detailing advanced use of these commands.

The first example uses Apple’s afplay, but since the AudioFile API seems to be incapable of understanding its own DRM (*.m4p), the second example uses qtplay from MacPorts.

  • Listen to the first 5 seconds of all tracks by Mute Math:
    mdfind "kMDItemAuthors == 'Mute Math'" | while read f; do afplay -s 0 5 "$f"; done
  • Listen to a random track of 148 – 152bpm:
    mdfind "kMDItemTempo >= 148 && kMDItemTempo <= 152" | qtplay -1 -- -

Given the pervasive nature of Spotlight’s metadata, the possibilities are vast.  Hint: SSH and “&”.