Index: trunk/LocationDo/LocationDo.py
===================================================================
--- trunk/LocationDo/LocationDo.py	(revision 211)
+++ trunk/LocationDo/LocationDo.py	(revision 212)
@@ -78,8 +78,15 @@
     if '4111 SC' in location:
         action.openInBackground('~/Documents/Research/Research progress.oo3')
-        # XXX wait for yt to be accessible
-        # XXX start NX
-        # XXX move windows
-        action.terminalDo('kswitch -p njriley@ACM.UIUC.EDU;(sleep 10;kswitch -p njriley@AD.UIUC.EDU)&! ;clear;ssh yt')
+        # XXX complain that NX has no creator nor bundle ID
+        action.openApplicationWithName('NX Client for OSX')
+        # XXX make these changes dependent on screen resolution
+        action.moveWindow('iTunes', 'iTunes', (2123, 1534), ifSizeMatches=(129, 65))
+        action.moveWindow('Adium', 'Contacts', (1280, 1553))
+        action.moveWindow('Adium', 'AOL System Msg', (1448, 1320))
+        # XXX need better way to do this
+        action.moveWindow('OmniOutliner Pro', 'Research progress', (1634, 847))
+        action.moveWindow('OmniOutliner Pro', '◇ Research progress', (1634, 847))
+        # XXX wait for yt to be accessible and Kerberos, then open the terminal window
+        # action.terminalDo('kswitch -p njriley@ACM.UIUC.EDU;(sleep 10;kswitch -p njriley@AD.UIUC.EDU)&! ;clear;ssh yt')
         action.setDisplayBrightnessPercent(0.9)
         action.setAdiumStatus('Working in 4111 SC')
@@ -89,4 +96,6 @@
         action.setAdiumStatus('At ACM')
     if 'Champaign' in location:
+        action.ensureKerberosPrincipalsValid(['njriley@ACM.UIUC.EDU',
+                                              'njriley@AD.UIUC.EDU'])
         action.openInBackground('~/Documents/To do.oo3')
         action.setDisplayBrightnessPercent(0.2)
@@ -158,14 +167,26 @@
                     elif bssid == '00:13:c4:ce:66:a0':
                         location.add('13[12]0 DCL')
+                    elif bssid in ['00:0e:83:05:78:02', '00:0e:83:05:77:42']:
+                        location.add('1304 SC')
+                    elif bssid == '00:0e:83:05:78:a2':
+                        location.add('3124 SC')
+                    elif bssid == '00:0e:83:05:76:b2':
+                        location.add('Siebel 2nd floor atrium')
                     elif bssid in ['00:14:1c:ad:5c:80', '00:14:1c:ad:64:50']:
                         location.add('MEB')
                     elif bssid == '00:02:2d:2c:cb:34':
                         location.add('B02 CSL')
+                    elif bssid == '00:11:5c:fe:31:00':
+                        location.add('CAB')
                     elif bssid == '00:13:c4:78:e1:a0':
                         location.add('Engineering Hall')
+                    elif bssid in ['00:0c:30:d4:b7:2d', '00:0c:30:d4:b6:70']:
+                        location.add('Illini Union')
                     elif bssid == '00:0d:93:ed:e0:bc':
                         location.add('340 Marlborough St.')
                     elif bssid == '00:40:96:5a:5e:0f':
                         location.add('BMI baggage claim')
+                    elif bssid == '00:12:0e:10:1f:83':
+                        location.add('Waterville Valley')
                     elif bssid == '44:44:44:44:44:44':
                         location.add('No AirPort network')
@@ -192,4 +213,6 @@
                     elif ssid == 'Wackyland':
                         location.add('340 Marlborough St.')
+                    elif ssid == '05B408706826':
+                        location.add('Waterville Valley')
                     elif ssid == 'CIRA':
                         location.add('BMI')
Index: trunk/LocationDo/action.py
===================================================================
--- trunk/LocationDo/action.py	(revision 211)
+++ trunk/LocationDo/action.py	(revision 212)
@@ -3,4 +3,5 @@
 from AppKit import NSWorkspace
 from appscript import app, k, its
+from appscript.specifier import CommandError
 import os, osax, subprocess, tempfile, SCNetworkReachability
 
@@ -8,6 +9,7 @@
 
 def ensureKerberosPrincipalsValid(principals):
+    # XXX still doesn't play well with the automatic ticket renewal the Kerberos app does
     kerberosApp = app(id='edu.mit.Kerberos.KerberosApp')
-    validPrincipals = kerberosApp.caches.filter(its.time_remaining != 'Expired').principal.get()
+    validPrincipals = kerberosApp.caches.filter((its.time_remaining.startswith('Expired')).NOT).principal.get()
     for principal in principals:
         if principal not in validPrincipals:
@@ -44,4 +46,8 @@
     return ws.openFile_withApplication_andDeactivate_(path, None, False)
 
+def openApplicationWithName(name):
+    ws = NSWorkspace.sharedWorkspace()
+    return ws.launchApplication_(name)
+
 def setDisplayBrightnessPercent(percent):
     # XXX create brightness module
@@ -58,4 +64,21 @@
         adiumApp.my_status_message.set(status)
     adiumApp.my_status_type.set(k.available)
+
+def moveWindow(appName, windowName, position, ifSizeMatches=None):
+    # XXX support locations relative to screen corners
+    systemEventsApp = app(id='com.apple.systemevents')
+    try:
+        if ifSizeMatches:
+            size = tuple(systemEventsApp.processes[appName].windows[windowName].size())
+            ifSizeMatches = tuple(ifSizeMatches)
+            if size != ifSizeMatches:
+                print "Window size didn't match: %s in %s" % (windowName, appName)
+                print "- Wanted %s, got %s" % (ifSizeMatches, size) 
+                return False
+        systemEventsApp.processes[appName].windows[windowName].position.set(position)
+    except CommandError:
+        print "CommandError: %s in %s" % (windowName, appName)
+        return False
+    return True
 
 def terminalDo(command):
