useful applescript

I’ve been hooking up my MacBook to the setup (mouse/keyboard/lcd) usually connected to a Windows machine over the last few days.  It works great except for the reversed Command + Option on the keyboard mappings.  I googled for something eloquent and found this;  Unfortunately whenever he did that it is outdated now.  I updated it for Leopard, and I can now just use Spotlight to execute "Change Keyboard" as I saved it as an Application to my Applications folder with that name.  Here is the updated version;


tell application "System Preferences"
    set current pane to pane ""
end tell

tell application "System Events"
    get properties
    tell application process "System Preferences"
        click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
        set commandKey to value of pop up button 1 of sheet 1 of window "Keyboard & Mouse"
        — DEBUG
        — display dialog commandKey
        —  Default, lets flip
        if commandKey ends with "Command" then
            — click the pop up button menu "Option", this menu does not exist until it is clicked in the GUI
            click pop up button 2 of sheet 1 of window "Keyboard & Mouse"
            — click "Command" of the pop up menu
            click menu item 4 of menu 1 of pop up button 2 of sheet 1 of window "Keyboard & Mouse"
            — delay briefly
            delay 1
            — click the pop up button menu "Command", this menu does not exist until it is clicked in the GUI
            click pop up button 1 of sheet 1 of window "Keyboard & Mouse"
            — click "Option" of the pop up menu
            click menu item 3 of menu 1 of pop up button 1 of sheet 1 of window "Keyboard & Mouse"
            — delay again
            delay 1
            — Not Default, lets flip it back
            click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
        end if
        — click "OK" to dismiss the sheet
        click button "OK" of sheet 1 of window "Keyboard & Mouse"
    end tell
end tell

tell application "System Preferences" to quit

more video for fun and profit

Well, I read more, and I played more.

First, the original video I posted sucked.  I couldn’t figure out why iMovie HD was degrading the video for the life of me.  I tried every encoding setup known to man, but just couldn’t figure it out.  Finally I realized that when I had originally hit "Create a New Project", I had selected to save it in MPEG, instead of DV.  This meant I was starting with already compressed video from the beginning!  I realized it when I had finally posted the first project all over the web and started to work on another video.

So.. I started over the first one with DV, re-did all the editing, re-exported, and it was the same as the original AVI quality.  Woohoo!  Next I spent a few hours scouring the web for what h.264 bitrates should be used to represent standard definition (480p) and high definition (1080p) video.  I’ve come to the conclusion that there is no clear direction amongst the world.  However, I have to make some decision, so my belief based on reading is that 2mbps for 480p and 8mbps for 1080p are appropriate with h.264.  Since those reference average bit rates, I will set the QT encoding to a max bit rate of 2.5mbps for 480p and 10mbps for 1080p.

My logic for the audio is pretty similar since I do all my MP3s in 192kbit VBR, and the AAC is set to 224kbit.  If I ever end up with video taken with a better audio feed than a basic handheld camcorder/camera, I’ll have to return and play with that part more.

macbook update

I said a while back there was a rumored software fix for my mouse woes on the MacBook.  They did indeed come out shortly after that and resolved my problems.  It’s a bit odd to use the mixture touch/click on a single surface still but I’m getting more used it every day.


I upgraded gallery to the newest release yesterday.  It adds a pretty sweet new flash slideshow I think everyone will like for the photos.  Let me know what you think.

I also upgraded the blog today, so let me know if either one causes anyone problems.

holy tutorial batman! synergy and encryption

Who remembers the bad TV show Batman?  Robin loved to say "holy <something> batman!".  Who could forget the bad animated pop-ups that said "BAM!"  "SMACK!"  "POW!".   Man that show was great.

In honor of Eddie’s comment about my holy tutorial I figured I’d give you all another one.  I find myself setting up convoluted/complicated things on my computers sometimes and then never documenting them anywhere.  Since a blog is supposed to be about not only sharing thoughts and ideas but also putting things back in to the Internet I figured I’d do my documenting here.

So next we look at synergy and encryption.

Synergy ( is an app that works in Windows, Mac OS, and Unix to let you share your mouse and keyboard.  I use it every once in a while at home, but I use it every day at work.  I have in front of me; three computers, four screens, and only a single keyboard and mouse.

The only down side to synergy is that there is no built in encryption.  I don’t feel safe typing in passwords without encryption, it’s just a bad idea.

Due to the PC based firewall that runs on our corporate IT standard XP machines I can’t run the synergy server in Windows, so all of my encryption is from the two Windows machines to the FreeBSD machine (same one I’m backing up to from the previous post).  In the past I’ve used PuTTY and manually opened it each time my PC booted.  This gets old after a couple years, and it also leaves a window open in my taskbar I wasn’t interested in staring at all the time.

First, install synergy clients on the Windows machines and the server on the Unix machine.  The Windows clients are pretty self explanatory, the only catch is you want to tell it the server is localhost since the connection will be encrypted locally via an SSH tunnel.  Also, make note of the Screen Name under Advanced, and make sure you have it set to AutoStart when you login.

On the server, make sure it’s set to start at boot (a million different Unix variants here, you’ll have to figure it out yourself).  Then create a config.  Here is what mine looks like;

section: screens

section: links
                right = Windows2

                left = Windows1
                right = FreeBSD

                left = Windows2

Now make it start.

Next, install myentunnel from

I used the base install so I could just control it starting from my startup menu.

Now install puttygen from

If you’ve already generated an OpenSSH Key in Cygwin as part of my previous post you’ll want to just import that one by going to the Conversions Menu selecting Import key, and opening your id_rsa from the home dir of cygwin/.ssh.  If you don’t have one already, you can just click Generate.  If you had to generate one, copy the contents of the public key and put them in the ~/.ssh/authorized_keys on the Unix host.  Make sure it’s chmod’ed to 600 so sshd can consider it secure and use it.

Now, save the private key, say ok to having to passphrase, and save it in your myentunnel dir as "keyfile.ppk".

Close puttygen, and open myentunnel.

Under the Settings tab that comes up enter the name of your SSHServer, Username.  I selected Connect on Startup, Reconnect on Failure,Use Private Key, and Verbose Logging.

Under the Tunnels tab, enter 24800:localhost:24800

24800 is the port synergy uses and this just makes it tunnel locally as 24800 and then on the remote host, forward the data to localhost 24800.

Now, click Connect, wait for the lock in the system tray to go green, and then click Hide.

Lastly, create a shortcut to the executable in you startup folder and you’re done!

With the SSH tunneling in place you can see synergy gets pretty powerful.  I can actually share a mouse and keyboard in my house when the laptop on my desk is VPN’ed in to work by SSH tunneling back in to the house.  It’s a *bit* slow, but it definitely works.

There are other alternatives here, including using stunnel, or even more cygwin work, but myentunnel seems to work great so far for me.