Fun with Mac OS X Preferences

pudge on 2002-08-14T15:08:14

Mac OS still uses Internet Config to some extent, but it is different than in Mac OS 9 in a few ways. First, there's no UI to edit all of the fields; so if you want to edit something, and it's not provided in the Internet prefs box, you're sorta out of luck. Second, it doesn't use the same file format; it uses the XML plist format.

So my problem is that in Eudora, I like using ProFont ("Programmer's Font", similar to Monaco, but easier to read for code at small point sizes) for messages, but I check Eudora's prefs to use Internet Config (for SMTP host etc.), and there's no way to change the default screen font from Monaco to ProFont.

One solution might be to port Mac::InternetConfig, and use the API. But I tried something else.

I opened /Users/pudge/Library/Preferences/com.apple.internetconfig.plist -- an XML file -- and poked around. Nothing in there for ScreenFont, the pref I want to set. I poke around a little more to figure out how to add it if I want to. A standard entry looks something like:

WebBackgroundColour ic-data ////////

OK, so what's the data? It looks suspiciously familiar. The first line of the XML file, after the declaration, is:



OK, so that file tells us:



Nice. Sure enough:

% perl -MMIME::Base64 -le 'print ord decode_base64(shift)' //////// 255

OK, so now I just need to get the data for ScreenFont, in the right format, then encode it in Base64. MacPerl to the rescue!

#!perl -wl use MIME::Base64; use Mac::InternetConfig; print encode_base64($RawInternetConfig{kICScreenFont()});

%InternetConfig gives a sane human-readable value (in this case, ProFont). But %RawInternetConfig provides the raw packed data. I encode it and print it out:

AAkAAAdQcm9Gb250AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAA4W4tIAA2QVAAi WYgDhACj97QAAAAiWYgAMzACAAAAAgCmiLIADt6oAA7enGj/90AApoirAAAAAAAID0xURVhUdHR4 dAANkFSIhAAiZJgDAwCj97QAAAAiZJ4AAAAAAAgAotoAAIEAAAAAAADMzMzMzMzMzACmiLpAnfFQ AKLTKAAiVlL///8AACJWQkCJXpYAotqg////AAAiVkI=

So I reformat it a bit to have the same line lengths as the other entries in the file, and end up with:

ic-data AAkAAAdQcm9Gb250AAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//// /wAAAAA4W4tIAA2QVAAiWYgDhACj97QAAAAiWYgAMzAC AAAAAgCmiLIADt6oAA7enGj/90AApoirAAAAAAAID0xU RVhUdHR4dAANkFSIhAAiZJgDAwCj97QAAAAiZJ4AAAAA AAgAotoAAIEAAAAAAADMzMzMzMzMzACmiLpAnfFQAKLT KAAiVlL///8AACJWQkCJXpYAotqg////AAAiVkI=

I quit Eudora, save the plist file, and reopen Eudora, and there it is as my new screen font: ProFont, size 9.

Yay!


Editing Property lists

gnat on 2002-08-14T15:32:54

You have something against the Property List editor? :-)

--Nat

Re:Editing Property lists

pudge on 2002-08-14T15:56:46

I don't need it, first of all. I also use command-line utilties for dealing with NetInfo.

However, it would be harder in this case, IMO, to use it. This is the particular data:

\0 \0\0ProFont\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0ÿÿÿÿ\0\0\0\08[‹H\0
T\0"Yˆ„\0£÷´\0\0\0"Yˆ\030\0\0\0\0¦ˆ² \0Þ¨\0Þœhÿ÷@\0¦ˆ«\0\0\0\0\0LTEXTttxt \0
Tˆ„\0"d˜\0£÷´\0\0\0"dž\0\0\0\0\0\0¢Ú\0\0\0\0\0\0\0\0ÌÌÌÌÌÌÌÌ\0¦ˆº@ñP\0 ¢Ó(\ 0"VRÿÿÿ\0\0"VB@‰^–\0¢Ú ÿÿÿ\0\0"VB


My options are to Base64 it and paste it manually, which as shown is pretty trivial, or I'd need to figure out the right hex format to put it in:
00090000 0750726f 466f6e74 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 ffffffff 00000000 385b8b48 000d9054 00225988 038400a3 f7b40000 00225988 00333002 00000002 00a688b2 000edea8 000ede9c 68fff740 00a688ab 00000000 00080f4c 54455854 74747874 000d9054 88840022 64980303 00a3f7b4 00000022 649e0000 00000008 00a2da00 00810000 00000000 cccccccc cccccccc 00a688ba 409df150 00a2d328 00225652 ffffff00 00225642 40895e96 00a2daa0 ffffff00 00225642
I preferred the former. It's a lot easier for me to wrap my head around it in the raw text file. Yes, it's hard to imagine why I am a Mac user at all. :-)

But even if I did use the plist editor, the rest of the steps would have been similar; I'd still need to figure out what format to put the data in, still need to use MacPerl to get the data and put it in that format, etc.

Base 64

TorgoX on 2002-08-15T08:16:44

I wonder why they base-64 encoded it, instead of just &-escaping it. You know, � to &255;. Not very compact, but then if they wanted compact, they wouldn't be using XML.

Maybe they just wanted to be able to have free whitespace, which I presume you can have in Base-64 but not if you're relying on &-encoding.

Re:Base 64

pudge on 2002-08-15T11:31:32

Maybe. Base64 sure looks "neater" than &#-encoding.