Category Archive: Mac

Gaining real estate on my SL MBP

I have a very busy menubar, lots of menubar extras, and it’s annoying that many of them wind up being covered up by the actual menus on my 13″ MacBook Pro. I used to use Unsanity’s Silk to reduce the font size (I was using Arial Narrow), but Silk even now hasn’t been updated to work in Snow Leopard.

However, I came across a “ported font” called Greyscale on the site, and installed it. So far, so good.

[Note! I haven’t even tried this after switching to Lion, I used the TinkerTool trick in footnote 2 instead.]

My menubar now looks like this:

Greyscale menubar

Below I outline what I did. I have had it running for something like an hour, with no real ill effects. But, pulling this off is a deep, dirty OS hack. If you do this, you’re doing it at your own risk.1

The procedure is: Get a copy of Onyx if you don’t have it already (this is to clear the font caches). Download the file from the forum link given above, open up the Protected and System folder aliases contained within. From the ProtectedFonts folder, move the LucidaGrande font to somewhere else for safekeeping (system password needed), move the LucidaGrande font from within the Greyscale archive into the ProtectedFonts folder (system password needed), move the LucidaGrande font from within the Fonts folder to the trash (system will alert you that this is weird). Then, in Onyx, go to the Cleaning tab, Fonts panel, ensure that System and Users is checked, and Execute. Restart.

Note: As far as I understand it, this will not work properly if you try to replace the font file in ProtectedFonts. Move it out and move the new one in, don’t just move the new one in overtop the old one.

What is happening here is this: The systemwide font that Snow Leopard uses for the menu bar, Lucida Grande, is being replaced. This is an important font, and SL protects itself against losing it by keeping a “repair kit” version of it in ProtectedFonts. So, first, we swap in our own font to its repair kit, then we remove the system font (causing it to repair itself, but with our new font instead). Cleaning the caches and restarting helps make sure no remnants of the old Lucida Grande are still in memory.

To undo this, repeat the same steps, only move the original file (that you kept for safekeeping) back into the ProtectedFonts folder after moving out the faux-LucidaGrande.

It’s not necessarily all flowers and bunnies, though. This really is completely replacing Lucida Grande. We’re not changing the font in the menu bar, we’re hiding another font in there under the name Lucida Grande. What this means is that everything that would have used Lucida Grande will now use Greyscale (though it will think it’s using Lucida Grande). And if you try this, you’ll see that Lucida Grande is used all over the place. Window titles, source sidebars, Growl notifications, everywhere, everywhere, everywhere. I’d really prefer it if it were possible to selectively replace the menu bar font alone, but this is apparently quite difficult to pull off.2

Still, I have more room now, and I can still read my screen.

1Another much less intrusive option is to use something like AccessMenuBarApps, which is not much more than a little app you can bring to the front with a hotkey or gestures and which has a very very small native menu bar app, leaving maximum space for menu bar icons. Of course any app with a small menu bar footprint can serve this purpose, but AccessMenuBarApps is pretty convenient.

2Something kind of like this can be accomplished by using TinkerTool and setting all of the configurable fonts to something other than Lucida Grande. I went in and changed everything that was Lucida Grande to Arial Narrow, and that works pretty well. The problem I have with Greyscale is that it is very hard to see the distinction between the numerals six and eight. If someone has converted Arial Narrow to be in the right format to drop it in, I’d probably do that instead of dropping in Greyscale. [Later note: One downside to using Arial Narrow (at least in Lion) is that it does not have the right characters to display the modifiers for keyboard shortcuts, so they wind up being displayed with characters like Ý. To solve this, I left my System font set to Lucida Grande, though it is a tradeoff between space and having the shortcut symbols.]

Sending EagleFiler metadata to BibDesk

I have a big EagleFiler archive in which I hold all of my PDFs, and as I add papers, I generally fill the “Title” field with the paper title and the “From name” field with the authors, as well as assign tags, etc. EagleFiler is generally my first stop when I acquire a new PDF. Plus, my EagleFiler library lives in my Dropbox, so I can get at these files from my iDevices as well.

However, when I want to add one of these papers to my bibliography, I have to go to BibDesk, make a new record, retype the title and author, and attach the PDF. And then I think: I should automate the export of the metadata someday.

Happily, that someday is today.

I have put together a simple Applescript that will look at the record(s) selected in EagleFiler, and create a corresponding new BibDesk record for each of them. It fills in the title, author, and source URL information from the EagleFiler metadata, attaches the file to the BibDesk record, and then does a couple of other things that are idiosyncratic to my particular filing system. In particular, it looks in the path to see if it is inside a “Journals” folder (in which case it is an article), or in “Monographs” (in which case it is a book), etc. It also looks to see if a tag called “look” was assigned in EagleFiler, and marks the “Read” flag in BibDesk if the tag is found. Obviously, these parts are only useful if you file things the way I do. But even if you don’t, it might be interesting to see how the script works.

I am no Applescript genius. In my initial tests, this ran kind of slowly, and there are probably better or more efficient ways it could be written, but it does seem to work.

Once a BibDesk record is created, the publication window is opened, and generally there needs to be some tweaking: fixing quotation marks, protecting capitals, fixing author lists to use “and” as separators, but it still saves some double-entry.

One installs Applescripts like this into ~/Library/Scripts/Applications/EagleFiler and then they are available via the scripts menu in the menubar.

-- Create a new BibDesk record from EagleFiler record
-- Paul Hagstrom, November 2010
-- This is probably kind of idiosyncratic.
-- My filing procedure is to have PDFs in EagleFiler with the
-- title in title
-- authors in from
-- There is very little chance that it will work without any need to edit
-- Maybe later I'll try to figure out how to tag things so that they'll
-- detect the right reference type, etc.

on run
	tell application "EagleFiler"
		set _records to selected records of browser window 1
		repeat with _record in _records
			set theTitle to _record's title
			set theAuthor to _record's from name
			set theSource to _record's source URL
			set theFile to _record's file
			set thePath to theFile's POSIX path
			set theNote to _record's note text
			-- special handling based on my idiosyncratic organization
			-- look at the path to see if it is a journal or what
			set theType to "article"
			if thePath contains "Journals" then
				set theType to "article"
			end if
			if thePath contains "Monographs" then
				set theType to "book"
			end if
			if thePath contains "Dissertations" then
				set theType to "phdthesis"
			end if
			if thePath contains "Edited" or thePath contains "WPL" or thePath contains "Conferences" then
				set theType to "incollection"
			end if
			-- special handling of tags.  If something is tagged "look" it goes on the reading list.
			set theRead to false
			set _tags to _record's assigned tags
			repeat with _tag in _tags
				if _tag's name is "look" then
					set theRead to true
				end if
			end repeat
			tell application "BibDesk"
				tell document 1
					set thePub to make new publication at the beginning of publications
					set type of thePub to theType
					set title of thePub to theTitle
					--at some point I might try to replace commas with "and"
					--and if theAuthor starts with "ed." put it in the editor
					--field instead, since that is my general convention in EF.
					set value of field "Author" of thePub to theAuthor
					tell thePub
						add (POSIX file thePath) to beginning of linked files
						if theRead then
							set value of field "Read" to 1
						end if
						make new linked URL with data theSource at end of linked URLs
						--at some point I might try to parse my filenames
						--they are generally authorYear-source.pdf
						--set value of field "Journal" to theJournal
						--set publication year to theYear
						set cite key to get generated cite key
					end tell
					show thePub
				end tell
			end tell
		end repeat
	end tell
end run

A nicer LaTeX bundle for TextMate

When a document I was trying to compile kept alerting me to fatal errors, but scouring the log file failed to reveal anything that should count, I decided I’d poke around a little bit to see if there were any updates to the LaTeX bundle for TextMate. I found, first, that it seemed to have actually disappeared from the TextMate svn repository, but, second, that there is a relatively nice version maintained by Adam Strzlecki on github. I haven’t done a great deal of exploration, but it does seem to be a bit faster, and there are a few added niceties to the autocompletion mechanisms.

I updated to the new bundle, but since I had made some changes to the old one (see Adding a little bit to TextMate’s LaTeX bundle and More TextMate LaTeX language editing), I decided to fork the existing repository and add those in as well.

Additionally, at present, the current bundle chokes a little bit on files that are within folders that contain spaces in their names. Compilation still works, but the links to errors that you should get in the status window are broken, as is the “jump to corresponding location in the PDF” command. I’ve fixed both of these problems in my fork of the bundle (though it is possible that there are hidden problems I’ve introduced, particularly in the thing that processes error links, I haven’t tried it with a complex master document).

Update: The sad truth is, this is not ready for prime time yet, at least not for me. I rely heavily on the dvi-ps-pdf pathway, and this bundle seems to have disabled it. I tried for a while to re-enable it, but it just wasn’t cooperating. Maybe in the lazy days of Thanksgiving break, but for now I would recommend against installing this bundle.

To install my fork of the TextMate LaTeX bundle, you need to remove the old one (maybe just put it somewhere safe in case you want to go back to it) from ~/Library/Application Support/TextMate/Bundles/ (maybe also check in /Library), and disable or remove the built-in LaTeX bundle. (I, perhaps unwisely, just pulled it out of the .app: right-click on the TextMate application, show package contents, open Contents, Shared Support, and Bundles, wherein is LaTeX.tmbundle.)

To install the new bundle, you need to have git installed. If you don’t, there is some information at github about installing git on Mac OS X.

That done, open a Terminal window and type thusly:

cd ~/Library/Application Support/TextMate/Bundles/
git clone git://

The next time you start TextMate, the new bundle should be active.

Now, back to that paper.

Printing handouts from the T

Once again, I arrive at the T stop just to see the train I needed to get to class on time pulling away. I still need to print my handouts, but I am barely going to be able to be physically there by the time the class is scheduled to start.

What to do?

Well, I have 20 minutes on the T, and my handout files are kept in my Dropbox folder, which means that my handout is actually on my office computer’s hard drive. And I have an iPhone on which I have installed iSSH. iSSH is a fabulous app, complete with VNC capability, so I figured: I’ll just put my office computer’s desktop on my phone, open the handout, and print.

Except something is configured wrong, or I’ve forgotten the VNC password, something is preventing me from bringing up my office computer’s screen on my phone. I can, however, still ssh in to the command line on that computer.

So: how to print from the command line?

Although there is rarely call to use it, it is relatively straightforward to send things to the printer, and the CUPS printing system installed as part of Mac OS X is smart enough to know what to do with PDF files, and can send options to the printer like: print double-sided, staple, print 2-up, etc. You just use the lp command. Here is the specific command I used.

lp -d printer_name -n 15 -o Collate=True -o Staple=1PLB -o number-up=2 -o sides=two-sided-long-edge ~/Dropbox/.../handout.pdf

Of course, this won’t work for everyone’s printer setup, one needs to know what the printer’s name is, and what options are available. But these are fairly easy to determine, based on things I learned from this page of the CUPS documentation.

If you need to find out what printers your computer knows about, enter lpstat -p -d at the command line. In the print command I gave above, I pretended that one of the printers was called printer_name, although really it was named after its IP address on the network. The number 15 I put there after the -n option is the number of copies to print. The options indicated with -o are printer-specific options for stapling, printing n-up, etc. You can find what options your printer supports using lpoptions -p printer_name -l.

So, as long as there is paper in the printer, and there are no forthcoming paper jams, it is possible to make the printer do its thing all on its own, so that I can pick them up when I get there and go to class. Fairly nerdy, but pretty cool. And occasionally practical.

TLU vs. TeXLive versions

Just like last year, when the preparations begin for the next version of TeXLive, it starts becoming difficult to use TeX Live Utility (a Mac GUI front end for tlmgr). Last year, this was a problem with the TLU app exclusively updating for 2009 before 2009 was released. This year, just now, there was a glitch (encountered upon updating tlmgr) that bumped my repository into thinking it is a 2010 repository. The signal was this:

tlmgr: package repository
The supported release as specified by the repository (2009)
does not match the release version of the installation (2010), bailing out.

This can at least for the moment (and if it crops up again) be solved by forcing the repository to report 2009. What the repository reports is given around line 50 of, which for me was found here.


Maybe this will be useful to someone else (or to me, later).

Snow Leopard broke my Finder habits

One thing that I’m noticing about Snow Leopard is that there are some subtle changes in the way the Finder works, that break habits I have. I don’t like the changes, I can’t see why they’re positive.

File copying: These are the most annoying things. If you have a couple of file copies running and one completes, the Copy window showing the progress comes to the front, disrupting anything you may be doing (e.g., naming a folder, which then gets named based on however far you got when the Copy window decided to assert itself). Further, there is some kind of weird (but not very accurate) file tracking that copying now does, so the window you copy a file into scrolls down to someplace like where the file landed, once the copy completes. Often it, or nearby files, will also be selected. There are no obvious preference settings to change this back to the way it was (basically: copy and do nothing else, don’t try to show me what a good job you’ve done when you’re finished). The worst thing is that it is often quite inaccurate, with unrelated things winding up selected (I assume because I copied a couple of things into the window and it was selecting based on the original state of the window). It’s also much harder to drag something into a window full of folders. There used to be kind of a “sweet spot” on the edge you could drag to in order to select the window rather than one of the folders within it. It’s still there, but it seems to be much smaller.

File renaming: Sometimes I have, say, an .mp4 file that I want to rename to be an .m4v file. You can rename it in the Finder, and you’ll get a dialog box coming up to say: “You sure? That’s going to change what kind of file this is treated as.” The default option is: “No, I’m not sure, keep the old file extension.” I used to be able to hit Tab to move the selection over to “Yes, I’m sure, use the new file extension” and then Space to confirm. Now, the Tab key does nothing, I have to mouse over there to click “Yes, use.” Update: Thanks to Will Robertson, who pointed out in a comment that this dialog can be completely turned off in the Finder preferences, in the Advanced tab.

I’ll look around when I have time to see if there are any Terminal commands that can set these as preferences, though I’m not sure there will be.

Thanks to KeyRemap4MacBook, I have my en-dashes back

Maybe I’m kind of a typography snob, but it just looks wrong to me when a range of numbers is indicated with a simple hyphen. When I’m typing a bibliography or something, I always use en-dashes. There used to be an easy way to do that, and it became a habitual thing in my typing: Command-fn-;, which is Command-Keypad-minus. Or it used to be.

A little while back, my mostly trusty white MacBook expired, and I replaced it with a new MacBook Pro. But the new MacBook Pro has no embedded numeric keypad. Why? Really, why? I don’t care if they don’t like the aesthetics of the little numbers on the keys, I can remember what a numeric keypad looks like. But, Apple actually removed the embedded keypad altogether from their new keyboards. So, now, I just wind up typing semicolons where I wanted en-dashes. In many of the places around the web that I see complaints about this, the basic response was “who cares? I never used it anyway.” Which is fine, except for those of us who used it all the time.

I just now came across KeyRemap4MacBook. This is a preference pane which can do all kinds of crazy remappings, but the cool thing, at least in Snow Leopard, is that you don’t actually need to turn on any of the key mappings. Just by being installed at all, it re-enables the embedded numeric keypad.

I am pleased to report that, having installed it, it seems to work. Granted, I have only had it installed for about 10 minutes, but it does not seem to interfere with either Quicksilver activation (which I have set to a tap of the fn key) or Google Quick Search Box activation (which I have set to a double tap of command), which were two of the things I was most anticipating having some kind of conflict.

I can now go back to my subconscious automatic routines, let my fingers do what they want, and get en-dashes in all the right places.

I spoke too soon

I swear it worked after the SL upgrade, but then it didn’t again. TextMate stopped compiling my LaTeX files. After a little bit of poking around, I saw that I have both python 2.5 and 2.6 installed. On what turned out to be a successful whim, I pointed the LaTeX bundle to python 2.5 instead of letting it default to python 2.6.

mate /Applications/

I changed the first line to point explicitly to python 2.5, and it worked.

#!/usr/bin/env python2.5 -u

Time Machine on disk images on local hard drives

I guess this is more Technology than it is Linguistics. But, anyway. I have a Time Capsule at home, my Macs back up to it over the network via Time Machine. The way this works is that there is a disk image (a special, fragmented kind of expandable disk image called a “sparsebundle“) on the Time Capsule’s drive, which gets mounted during the backup process and then the backup takes place on this disk image.

Normally, when you use Time Machine on a locally-attached hard drive, there is no disk image involved, it just puts the backup into a folder called “Backups.backupdb“.

I have a pretty big external hard drive in my office, and I thought I’d like to set up a Time Machine backup there too. But it’s a really big hard drive, and I want to use it for other stuff, not just Time Machine. Yet, Time Machine likes to eat up all the space it is given access to. Re-partitioning the drive (in order to impose a hard limit on the size of the Time Machine backup) would mean erasing the drive, and I already have a bunch of stuff on it that I’m too lazy to move off and back on again. What would be ideal is if that same backup scheme that the Time Capsule uses, namely a disk image (which can have limits placed on its size), which could be used on the local hard drive.

Mounted disk images do not show up as valid Time Machine target drives, even when you monkey with the Terminal and set the hidden preference to allow unsupported network drives. However, I believe that I have discovered that, if you have an appropriately named disk image on the drive, Time Machine will use it.

So, here’s what you do. We will need two pieces of information: the MAC address, and the Computer Name. To get the MAC address, choose About This Mac in the Apple menu, click on More Info to bring up System Profiler. Click on Network in the side panel, then on Ethernet in the top panel. Near the bottom, find the MAC address, which is a 12-digit hex string like 01:23:45:67:89:ab. Take note of this number. You will use it shortly, but without the colons.

To get the Computer Name, choose “System Preferences” under the Apple menu, and click on Sharing. At the top, there is a Computer Name (often something like “Paul Hagstrom’s Computer” if you haven’t changed it to something intentionally). Take note of this as well.

Find Disk Utility (in the Applications folder, within the Utilities folder) and launch it. In the File menu, choose New, Blank disk image. Set the image format to: “sparse bundle disk image“. Set the Volume Name to be “Backup of Computer Name” (e.g., “Backup of Paul Hagstrom’s Computer“, substituting in whatever your Computer Name was). Set the size to be something appropriate, I picked 160GB, which might even be a bit on the small side. To do that requires picking a custom size, changing the popup to “GB” and typing 160. Finally, in the Save As field at the top, enter “Computer Name_MAC address.sparsebundle” exactly like that (e.g., “Paul Hagstrom’s Computer_0123456789ab.sparsebundle“). There are no colons in the MAC address when you are choosing the filename for the disk image, and there is an underscore between the Computer Name and the MAC address. All set? Hit Create. It’ll be pretty quick, because a sparsebundle is only as big as the data that’s been saved on it, and there hasn’t been any saved there yet.

When the image is created, if it isn’t mounted automatically, double-click on it so that the volume “Backup of XX” becomes available on the desktop.

Last step requires the Terminal (also in the Applications folder within the Utilities folder, same place Disk Utility was). Double-click on the Terminal to open it, and type the following, where by [tab] I mean “hit the Tab key”: “cd /V[tab]Back[tab]” and the hit return. This should have expanded to something like “cd /Volumes/Backup of Paul Hagstrom's Computer/“. Type “sudo touch” (that has a space between sudo and touch and one between touch and the period, but then no further spaces) and hit return. You might get a message about using the power of “sudo” only for good if you’ve never done this before. Type in your password (the one you use when installing software, etc.). Now, type “cd /V[tab]XXYY[tab]” except instead of XXYY, type the first couple of letters of the hard drive on which you will be placing this disk image. And do the same thing as before, “sudo touch“. You may not need to enter the password the second time if you did this soon enough after the first time. Then, quit the Terminal application.

Back in the Finder, eject the “Backup of XX” drive, and make sure that the sparsebundle you created is sitting at the top level of the hard drive it’s going to live on.

Now, you should be set. Open System Preferences, and go to Time Machine. Click on “Change Disk…” and pick the disk on which the sparsebundle lives. You’ll also want to probably want to turn Time Machine off (it’ll have switched on automatically) and click “Options…” and exclude various things from your backup so the backup isn’t unnecessarily huge. You can always reinstall the system from the Install DVD, after all. I generally exclude system files, and various transient folders like my Downloads folder, /Library/Caches/, ~/Library/Caches/, ~/.dropbox, and other things. Then Turn Time Machine back on, and choose Backup Now from the menu bar item or from the dock menu. What you should see happen is that it’ll think briefly and then your “Backup of XXYY” volume will automatically be mounted. This will look familiar happening for anyone who is used to doing Time Machine backups over a network. But that means it worked: the backup is now going to the sparsebundle on your local disk.

Having said all that, I have not really stress tested this. I trust that the sparsebundle will not exceed the size limit that I imposed upon it during its creation (160GB), but I will have to wait a while for it to fill up so I can see what happens. Perhaps I’ll post an update later. But I was pleased to see that it was relatively easy to get this far.

(A footnote: The procedure I outlined above is not exactly what I did, although it should work. If it doesn’t, what I actually did was this: I did a Time Machine backup straight to that external drive first. Then, I created the disk image as described above and put it on the external drive. Then I renamed the “Backups.backupdb” using sudo in the Terminal [sudo mv Backups.backupdb Backups.backupdbx], so Time Machine wouldn’t find it, and then started Time Machine. It found my sparseimage and started the backup over. At which point I dropped Backups.backupdbx into the trash and emptied it away. I don’t think that extra step of doing the initial Time Machine backup without the image was important, so I omitted it above. But if you try this and it doesn’t work, you could also try doing a first, possibly partial, backup without the image, and then move to the image.)