New Website

31 March 2009

If anyone is still reading here, I thought I should add a note that Arielle and I are now blogging at jungwirths.com.

Centering Text in the Gimp

9 June 2008

Here is a problem I thought would be easy, but it looks like it’s actually rather difficult, and Googling didn’t turn up any solutions. Suppose you have a document in Gimp with a bunch of text layers, each above another on the page like in a wedding invitation, and you want everything centered. First, set the text’s alignment within each text box to “centered.” That gets you part of the way there, by centering the text within each text layer, but the layers can still be off-center with respect to the page. So now choose the centering tool from the tool palette. It looks like a box with outward-pointing arrows on all four sides. Set the “Align Relative to” dropdown to “First item.” Then go to your image. Click on the background layer first. Then start shift-clicking on the text layers. (There must be no layers covering the text layers, even transparent or invisible ones.) Once all the text layers are selected, press the horizontal centering botton. It looks like this:

    ->|<-

That should center all the text layers based on the background layer, without moving the background layer.

Mac OS X: Changing the Icon for a File Type

16 May 2008

How does OS X decide what icon to show for documents? The rules are quite complicated. Here they are for 10.4, as best as I can tell. Please note that if you’re going to change any files, you should back up the old versions first! Don’t blame me if you wreck your system. . . .

Forcing an icon on an individual file

First, you can copy/paste an icon into the Get Info box, to force a certain icon for a certain file. This overrides all the other rules. First, get an icon in your clipboard. Then go to the file you want to change and open its Info box. Click on the old icon, in the upper-left corner, and press Cmd-V. Voila! You’ve pasted the new icon. If you want to revert to the default, highlight the icon in the corner and click Delete. This does not give you a blank icon; it gives you whatever icon is the default for this type (which may still happen to be blank).

I’m not sure where Mac stores the data for these one-off icon overrides. At first I thought the .DS_Store file would be a natural place, but it appears that is not it. (Incidentally, if you want to stop Mac from adding .DS_Store files to networked drives, type this command: `defaults write com.apple.desktopservices DSDontWriteNetworkStores true`.) Perhaps the file’s icon is part of the HFS+ filesystem, hidden in the resource fork. That seems like the most Macish thing to do, but on OS X I don’t know how to confirm it. The closest I can come is running this command:

$ /Developer/Tools/GetFileInfo -ac somefile

That prints “0” if the file has a default icon, and “1” if it has a custom icon.

There are several ways to get an icon onto the Clipboard so you can paste it into a Get Info window. If you open an .icns file in Preview, make sure you can see the Drawer (Cmd-Shift-D), then if necessary click the triangle to show all the icons contained in the file. There should be several for various sizes. But no matter what icon size you use, copying from Preview and pasting into the Info box gives bad results. Weird artifacts show up in the images like static around the edges, and transparency seems to get lost. Some people report better results with GraphicConverter, although when I try copying from there, I can’t paste into Get Info at all. If you can find an icon that already has your image, open its Info box and copy from there. That yields correct results. You may also be able to open the Info window of the icon itself and copy from there, but often these files simply have the default .icns icon, so there is nothing interesting to copy.

Setting an icon for a file type

If you haven’t assigned a specific icon to a specific file, files’ icons are determined by Launch Services (LS). There is an LS database which associates file extensions with icons and applications. You can use the `lsregister` command to manage this database. This command is hidden away in a deep folder, so to run it you should use `locate lsregister`. If it bugs you to keep typing “`locate lsregister`,” you could just symlink it. This command will do the trick:

$ sudo ln -s `locate lsregister` /bin/lsregister

I think this is a nice convenience, but in this article I’ll assume you haven’t symlinked anything.

To see everything in the LS database, type:

$ `locate lsregister` -dump

You’ll probably want to redirect the output to a file or pipe it into less, like so:

$ `locate lsregister` -dump | less

You’ll see that the LS database has entries for bundles, volumes, and handlers. A bundle is more or less an application, like /Applications/TextEdit.app or /Applications/OpenOffice.org 2.4.app, but there are non-app bundles like /System/Library/CoreServices/CoreTypes.bundle and /Library/Spotlight/Microsoft Office.mdimporter. Within a bundle there may be lists of types and claims (indented). If I search my database for “.doc,” I find that CoreTypes declares a type for Microsoft Word files. Spotlight declares both a type and a claim. TextEdit declares a claim. I don’t know what a type is for, but it’s claims to matter to us here. A claim includes a role. Roles I’ve seen include “importer” (Spotlight), “viewer” (TextEdit), and “editor” (OpenOffice). A claim may also suggest an icon for the document type. In my database, no claim actually does this for .doc files, but presumably this is how you’d tell the Finder how to display files of that type.

Near the bottom of the lsregister output is a list of handlers. In my database, the handler for .doc files, for all roles, is org.openoffice.script. This happens to be the identifier for /Applications/OpenOffice.org 2.4.app! Evidently this is how your Mac knows what to use for the `open` command (aka double-clicking). To see what handlers you’ve associated with what file types, type this:

$ defaults read com.apple.LaunchServices

But back to the LS database! If you’ve owned your Mac for a while, you may see some silly entries here. For instance, I see entries for /Volumes/OpenOffice.org/OpenOffice.org 2.4.app, because I installed OO by downloading a .dmg file. I also see /Applications/OpenOffice.org 2.2.app, although I’ve deleted the 2.2 version from my system. To clean out these old entries, you can “rebuild” the database. This is a bit like “rebuilding the desktop” in pre-OS X days. Just type:

$ `locate lsregister` -kill -r -f -domain system -domain local -domain user

On OS 10.5 systems, it appears this command has changed to:

$ `locate lsregister` -kill -r -f -all system,local,user

Note that each user has his own LS database. If you run lsregister through sudo, you are changing root’s LS database, and your own will appear unaffected. Therefore you should make sure you run lsregister as yourself.

Rebuilding the database is also how you can tell your Mac to re-read applications’ Info.plist files. If you want to use particular icons for particular file types, edit an application’s Info.plist, then run lsregister. For instance, we could use this process to change the icon for .doc files. Suppose you’re cheap like me, and you have OpenOffice installed but not Microsoft Word. OpenOffice is too polite to declare an icon for .doc files, so they appear as completely blank icons. If this annoys you, you can change the Info.plist file in OpenOffice to show its icons for .doc files. I’m going to assume you’ve editted an XML file before. If not, you might want to read up about it first. If you know what you’re doing, open the .plist file and remove the line saying, “<string>doc</string>” from the long list of file extensions OpenOffice knows about. Then add a separate dictionary like this:

    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>doc</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>oo2-writer-doc.icns</string>
        <key>CFBundleTypeName</key>
        <string>Microsoft Word document</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
    </dict>

You should add this <dict> element as an immediate child of the huge <array> element—in other words, as a sibling of the many other filetype <dict> arguments you see.

I don’t know if there is some other place you can add data like this on a per-user basis. It seems unfortunate to change the application’s own .plist file. You need root privileges, your changes affect all users, and you lose your work if you ever upgrade. I guess there is probably somewhere in your home directory you could make similar changes, but I don’t know where it would be.

Finally, rebuild the LS database. Since you’ve only changed one file, you don’t need to re-read everything. You can just use a command like this:

$ `locate lsregister` -r -f /Applications/OpenOffice.org\ 2.4.app

That accomplishes the job of changing icons for a whole file type. But there are still a few more questions I’d like answered.

First, can a document ever inherit its icon from its handler’s application icon? That is, if your Mac doesn’t know what icon to use for a document, but the document has a handler, will it just use the application’s own icon? It appears to me that this never happens. A perfect example is the .doc file. OpenOffice was declared as its handler, but the icon was still blank. Unless there is some extra complexity here, it looks like document icons are completely distinct from application icons; they must be declared explicitly.

Second, what happens when two apps each declare an icon for the same file type? Having made my .doc change in OpenOffice, what if I now installed MS Word? Both OO and Word would declare an icon for .doc files, so which would I see? I think probably Mac uses whatever icon is preferred by the document’s handler. So if I went into Get Info, changed the “Open with” dropdown, and pressed the “Change All…” button, I’d see the icon declared by that application. If I opened .doc files with OO, I’d see OO’s icon. If I opened .doc files with Word, I’d see Word’s icon. If the handler declared no icon, then I think the icon would be blank, even if another application declared a non-blank icon for the same type. Most of this paragraph is just theory. I haven’t tested it, but it seems consistent with experiences I’ve read elsewhere.

Other Files

There are a few other files associated with Launch Services. I’m not sure what these two do, but they exist:

/Library/Caches/com.apple.LaunchServices-0140.csstore
/Library/Caches/com.apple.LaunchServices-014501.csstore

Apparently those numbers are associated with your user account. There is also a file here:

$HOME/Library/Preferences/com.apple.LaunchServices.plist

Although this is a .plist file, it seems to be binary. This is the file that holds the data we saw above by running `defaults read.`

Color xterm with Mac OS X

11 May 2008

I’ve been putting up with a certain Mac annoyance for almost a year now, and I finally got around to finding a real solution. Mac’s Term application sets the TERM environment variable to “xterm-color.” Unfortunately, if you ssh somewhere else (say to a Solaris 8 machine) and try running vi, that TERM value is not recognized, and vi won’t start. The solution proposed on various other parts of the web is to open your Term preferences and set TERM to “xterm” instead of “xterm-color.” That makes the remote vi happy, but what a sad solution! You sacrifice color ls and vim syntax highlighting.

Tonight I did a bit of reading in ssh(1), and I saw that you could use ~/.ssh/environment to export certain environment variables. I added “TERM=xterm” to that file, and it made the remote vi happy. Note that the remote machine must permit you to pass environment values this way. You may need to change its sshd_config file to read:

PermitUserEnvironment yes

If you’re not allowed to do that, there is an alternative. Actually, it might be a better solution regardless.

A big drawback to the first approach is that you might only want to report a non-color TERM variable to certain machines. In that case, I suppose you could write a function to set and unset the variable before and after the ssh command. With a function, you also don’t need any remote sshd permissions. This code seems to work pretty well:

function sshbw {
   export TERM=xterm;
   ssh "$@";
   export TERM=xterm-color;
}

So there you have it: color on your machine, and an acceptable TERM on the remote machine.

First Ever Greek Scrabble

4 October 2007

Well, I know I haven’t posted anything since I moved to Philadelphia. There is plenty I could write—it’s been a great program so far—but this just had to go up. Five other postbaccers joined me for dinner and my first ever game of Greek Scrabble! Here is the board:

We used Little & Scott and Cunliffe’s Homeric Lexicon. You could check words before playing, but you weren’t allowed to browse. You could play any form you liked. Iota subscripts were “free.” I’m really impressed with what some of my classmates came up with! Who knew that ἅψος means “joint”?

Greek-Vietnamese

18 June 2007

After vespers on Saturday, someone suggested we go out to eat at Pho Saigon. But I heard “Φὼς Ἱλαρόν.” There’s a restaurant in Riverside called Φὼς Ἱλαρόν!? Well, there is now. I’ve decided that henceforth I will so refer to that place and all other Pho Saigons in the world. And if I ever open my own Vietnamese joint, it will be Φὼς Ἱλαρόν.

Life is Exciting

18 June 2007

Some of you may have heard crazy rumors about my pulling up stakes and taking to the road yet again. Alas, it is all true. So here is the story. This Fall I’m going to start a post-baccalaureate in Classics at U Penn, in Philadelphia. It is a one-year program intended mostly to prepare people for a Ph.D. All the Classics Ph.D. programs out there say, “If you didn’t major in Classics, definitely do a postbacc first. And maybe you should do one anyway!” Basically you just read Greek and Latin all day long. My idea of a great time!

Then two Mondays ago (the day before I went to Boston for a week) I got a surprise. Since I’ve only had one year of Latin, they want me to come out early and do an intensive second-year Latin course from July 2 to August 20 (or 10?…). It is 16.25 hours of Latin a week, and that’s just the class time. Yikes! But it sounds like a great opportunity, so I’m going to go. My Latin does need a lot of work.

During the Fall I’ll begin applying to Ph.D. programs. I’ve only done a little research, but I know that Berkeley, UCLA, and U Chicago are all top-rated schools with Byzantinists on staff. Fr. J wants me to apply to Oxford. I’ll send them an application, but I’m not sure I’ll be able to afford it. If my computer work keeps up—and it sounds like it will—then I think fifteen hours a week will just about cover me. Oxford would be pretty amazing.

My teaching interests are fairly traditional—intro to Greek & Latin, Homer, Sophocles, Cicero, Seneca, et cetera—but my research interests are more in Byzantine and patristic studies, especially philology and translation. I’m still not quite sure which sort of Ph.D. would be best. I’m inclining toward Classics, but perhaps patristics, theology, or Byzantine history would be good fits, too. Mostly you just need a good advisor. The advice I keep getting is “Do whatever you’re interested in, and find the program that lets you follow your interests.”

It is pretty exciting!

Little Roses

18 June 2007

It’s been a long time since I’ve written an update on my little roses. The one surviving stem is in the garden below a bougainvillea and behind a daisy plant, trying to stay out of the sun. But it keeps stretching its arms in that direction. It’s just put out a bud:

A while back I tossed the dead stems of my other five poor children and planted a few new ones. This time I tried two or three stems per pot, and I took them from all over the yard. I am trying to keep these babies out of direct sunlight:

Just the other day there was an article on roses in the Redlands Daily Facts. Here is what I learned:

First, I discovered that the white rose (the one that may soon blossom!) is an Iceberg, a floribunda. Floribundas are a traditional variety of rose with long-blooming, clustered flowers, but they are apparently high-maintenance. Oh well, she is worth it!

I still haven’t replaced the red rose from the front yard, which is called a Mr. Lincoln (hybrid tea). In my pots this time I put some backyard roses. I don’t remember exactly which ones I picked, but they were probably these:

Queen Elizabeth. This is a pink rose, a grandiflora. Grandiflorae have big flowers (of course) on big bushes.

Dolores. This is another tea rose, but Mom says it is red, pink, and white. I don’t remember clipping any such roses. Hybrid teas are admired for their spiraling blooms with elongated centers, but they are also high-maintenance.

Summer Sunshine. This is a yellow rose, another hybrid tea.

There are a couple roses by the front door I may have clipped, too: a yellow one and a red one. But I couldn’t find tags on them to tell me their names.

According to the Facts article, older roses like floribundas and hybrid teas have richer aromas than more modern shrub varieties. They also produce better-formed bushes and “large, single blooms on long stems that show well and last long in a vase.” But people like the shrub varieties because they are more resistant to disease and cold weather. The high-maintenance roses need to be covered in the winter. Is that all? That is a kind of high-maintenance I can handle.

ΛΕΞΟ ΦΡΕΝΕΙΑ!

3 June 2007


Yesterday was like Christmas. My friend K from seminary came home, and he brought a bunch of things I purchased in Greece last summer. Since I was going on to Cyprus, I gave them to him to take home, but then when I didn’t go back to St. Tikhon’s, they were in Pennsylvania and I was in CA. For whatever reason, I neglected to pick them up when I retrieved all my other belongings. The most exciting thing he brought back was ΛΕΞΟ ΦΡΕΝΕΙΑ! As the box says, it is the “classic tabletop word game”—yes, Greek Scrabble! I’ve sought a Greek Scrabble set for years, and at last I have it. It was a little beat up from all its travels, but none of the pieces were hurt. Actually, I wasn’t too sure that it even was a Scrabble set, but it turns out that’s exactly what it is. “Τριπλή Αξία Λέχης!” I’ve even managed to wheedle three other guys into playing with me. Let me tell you, the Fuller student was very reluctant. What are they teaching at that liberal fortress?

My house rules will be Bring Your Own Dictionary, and anything goes as long as you can verify it. I’ll bring my Homeric lexicon, BDAG, and the big bad Oxford blues brothers. All dialects are fair game. Proper nouns are permitted. You can play any inflection you like, so long as you can name the form. (“Masculine dative plural perfect middle/passive participle!”) You must give a basic definition of the word you play.

This is going to rock!

Five Thieves

28 May 2007

I received one answer by email to my last puzzle; it was right. Congratulations, Presbytera! I’ll post the answer now in the comments section. Here is another riddle:

There are five thieves who have just robbed a traveler of 100 gold pieces. Now they have to divide up the booty. All five abide by a Code with the following stipulations:

  • All decisions are made my majority vote. The losers all die.
  • The eldest keeps proposing whatever is to be voted upon, until a proposal passes.
  • In case of a tie, the side with the eldest member wins.

So what should the eldest propose to ensure that he walks away with the most gold pieces? You can assume that all the thieves will vote out of pure self-interest; none will sacrifice himself to hurt another. Moreover, every thief knows this about every other thief.