Packages are Cool!

I really like the way Apple decided to ‘package’ applications, plugins and the like with MacOS X. It actually makes it easy to see how stuff works. Take basic applications, and most of them are just an executable, but it’s easy to add modularity, and replace GUI elements and so forth.

I’ve grown tired of Toast: it seems to fail more than half of the time when burning DVDs, and I know the media is good, because Disk Utility has no problems burning! I intended to make an AppleScript that burned the selected disk image to a DVD/CD, but found that Disk Utility was not scriptable.

But there is a CLI command called hdiutil that can do most of the stuff Disk Utility can (at least with disk images). The command to burn an image to a Recordable Drive is:

hdiutil burn <imagename>

All I need to be able to do is get this to happen as a contextual menu. As far as I can tell, it should be possible to do this from AppleScript, or python, or bash.

Even better, I should be able to automatically create the <Name>.plugin/* directory structure, and what the contents need to look like, as soon as I can find out exactly what needs to be where!

New Browser Window Gripe

<rant> With the advent of two ’new’ features to web-browsing/internet use, the idea of hyperlinks in web pages opening up in a new window is truly evil. Tabbed browsing is a godsend to users like me, who like to have a whole series of pages open at once. Being able to have the whole shebang in one window, and just choose between them as they load is magnificent. Probably more important in terms of alteration to browsing is the development of RSS news-readers, and the saturation of RSS feeds amongst web-sites and blogs. What annoys me now, since with every news site I read being viewed initially in NewsFire, and then in Camino if I want to read more, (I wish they would all have full text feeds, though!), I only ever look at one item at a time in Camino. That is, I don’t look at front pages of news sites. So when I click on a link, I want the page I’m viewing to be replaced by the link I’m clicking on. If I didn’t, I’d Command-Click on the link, and open it in a background tab. Yet some sites: such as MacDailyNews, and others, still insist on off-site links opening in a new window. And when I click on one of these links, I have to close the window it opened in, and then Command-Click on the link again. It’s really starting to annoy me! </rant>

Maybe I’ll just remove these sites from my feeds list…which is getting too long, anyway!

SubEthaEdit accepts piped text.

If you have installed SubEthaEdit and the command line tool, see, you can configure --help | see and SubEthaEdit will load up the piped text!

MacOS X Slowdown II

I had noticed my iMac 1.25 GHx slowing down. Here’s what sped it up most:

  • Getting more RAM. I upgraded from 256 Mb to 768 Mb. Applications loaded faster, particularly when lots of them were already running. Especially noticeable when other users were still logged in.
  • Cleaned Application cache. Using System Optimizer X I was able to do this, which while it makes each application pop up a dialog the first time it is run via a double-click on a document, fixes corruption in the Application Cache, enabling applications to load much faster. This includes the Finder, so it only takes seconds (instead of minutes) to log in.
  • Update executable library prebindings. Since this too was done with SOX, I wasn’t able to tell which of these two made the biggest difference.

No, I’m not affiliated with SOX, and apparently it’s possible to do just about everything here with CLI commands, I just don’t know what they are yet…

Logging in from PC to MacOS

I have a few aliases and functions running in my ~/.profile, and some of them run MacOSX applications - for instance I like to edit files in SubEthaEdit, but I like to just use the word edit as the command to start the process. This is all well and good, until I’m remotely accessing a command line only, and try to edit a text file. If I’m logged into the Mac, up pops SubEthaEdit, and if I’m not logged in, I see kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only INIT_Processeses(), could not establish the default connection to the WindowServer.Abort trap Not much fun at all. So I wrote a function that will run the right program if I am remotely logged in. I found that Terminal sets the environment variable TERM_PROGRAM to 'Apple_Terminal'.

1
2
3
4
5
6
7
8
function edit
{
  if test `echo $TERM_PROGRAM` == 'Apple_Terminal' ; then
      open -a 'SubEthaEdit.app' "$*" &
  else
      pico "$*"
  fi
}

So far so good. But when I exit pico from my other terminal, I see an error of: -bash: test: ==: unary operator expected What’s happening is that the echo $TERM_PROGRAM is displaying "" (empty string) which test doesn’t like on the left hand side of a “==”. So the first lines of my ~/.profile are now:

1
2
3
if test `echo $TERM_PROGRAM""1` == '1' ; then
 export TERM_PROGRAM='Unknown'
fi

This took me a while to twig to - for ages I was just happy to have the error appear! The only issue with this is if I telnet from my imac (where the variable is set) into the same machine - you then lose the ability to automatically run the graphical programs set up in the functions. The other programs I use differently according to where I am are:

  • appswitch - use as a replacement for ps, kill, and to show/hide running programs.
  • SubEthaEdit - use as edit, and sedit (edit as Super User).
  • openman - a new window for each man page, allowing them to stay open while I keep working.

I also have a function called browse, that opens the current (or supplied) directory in the Finder. I’d love to be able to tell Windows Explorer to open this, but this would require some heavy duty inter-machine communication.

PuTTY shortcut

I sometimes have to use the PC next to my imac, and when I want to start a shell session, I use PuTTY. Now, usually I have to go through the process of either filling in the address of my mac, or click on the profile and load it, before clicking open. However, it’s possible to just edit the Windows Shortcut, and add the name of the server (or IP address) after the Target: information. Make sure the server name or address is not inside the quotes, and there is a space between them. Now, double-clicking the shortcut will connect to the server. It’s also possible to connect to a different port number. Update: If I’d read the FAQ, I’d know you can also use a -load mysessionname switch to load all of the settings from a saved session. Now if I could just get MacOSX telnetd to accept environment variables from the telnet client!

Cross Compilation NSLU2/MacOSX

So, I’ve built the toolchain - it’s about 69Mb raw, which zips to about 26Mb. Tarring and BZip2ing it reduces it to 18Mb. What I want to know is: is it only the stuff in bin/ that is used when cross-compiling? If so, this compresses to around 3.6Mb, which is small enough to post for others to use… Also, it’s possible to just copy the armv5b-softfloat-linux-* files (I used ln, so they are still in the original spot, but take up no extra room) to a place in your path. From what I’ve just read, the only thing really used is the compiler, but surely the linker is too. I have built a hello.c program, but cannot test it until I get my NSLU2.

NSLU2 MacOSX Toolchain

I’ve just paid for (and expect to receive in the next couple of days) a large (160Gb) USB Hard Drive, and in the next week or so I’ll also buy a Linksys NSLU2 NAS device, to share the HDD with all devices in my network. One of the reasons I decided on this route is the extreme hackability of the NSLU2 - it comes with a cut-down version of Linux with only SMB sharing turned on, but by flashing a new ROM it’s possible to set it up as a complete server. I aim to use it for mainly sharing files, but just for fun I’ll try and build python for it. I had a whole lot of experience building python for BeOS/PPC a few years back. It started to run into problems when building sockets and anything that used mmap(), and after about 2.2 I’m not sure I ever got it to work correctly again. Building the cross compilation toolchain to allow me to do this from MacOS X is quite complicated: you have to download about 60Mb of source code, and then build it. More details on this page. My notes on the topic follow: Make sure you reference the nslu2/bin directory in your path before the other location where the tools you installed are. Bash looks in the order they appear in the environment library list, so if expr is in two places, the first one it is found in is used, for example. The good news is, if the files have been downloaded, and the build fails, it is smart enough not to try and re-download them. Make sure you follow the instructions carefully - I did a make install instead of the cp src/expr $HOME/local/nslu2, and it failed dismally.

Most Played Music Meme

Most Played Music Meme Originally uploaded by Michael Heilemann.

Follow the instructions…

Zire Screen part 2

Well, it didn’t seem to completely fix it. Ages ago, after reading some book (called something like “How to do Everything with Your Palm (TM) Handheld, Third Edition” (Dave Johnson, Rick Broida) I stuck some tape over the Graffiti area, and I think this was causing (or contributing to) the problem. Since some of it was almost under the lip surrounding the screen, it was a little hard to remove. Almost all gone now, and the problem seems to be gone. Or nearly, anyway.