2 global needVerticalAdjust
 
   3 global desiredInitialVerticalOffset
 
   5 on makenewTab given theme:themeName
 
   6         tell application "Terminal"
 
   8                 tell application "System Events" to keystroke "t" using command down
 
   9                 repeat while contents of selected tab of front window starts with linefeed
 
  12                 set current settings of selected tab of front window to first settings set whose name is themeName
 
  16 on newPhoneTerm for phoneColor by phonePort
 
  17         set horizontalOffset to 50
 
  20         tell application "Terminal"
 
  22                 if phoneColor is equal to "Red" then
 
  23                         set currentTheme to "Red Sands"
 
  24                 else if phoneColor is equal to "Green" then
 
  25                         set currentTheme to "Grass"
 
  26                 else if phoneColor is equal to "Beige" then
 
  27                         set currentTheme to "Novel"
 
  28                 else if phoneColor is equal to "Black" then
 
  29                         set currentTheme to "Pro"
 
  30                 else if phoneColor is equal to "Cyan" then
 
  31                         set currentTheme to "Cyan"
 
  32                 else if phoneColor is equal to "Orange" then
 
  33                         set currentTheme to "Orange"
 
  34                 else if phoneColor is equal to "Beige" then
 
  35                         set currentTheme to "Novel"
 
  37                         set currentTheme to "Ocean"
 
  40                 -- make a new window with the execution of a trivial command
 
  43                 -- load up the window id of the window we just created
 
  44                 --      set window_id to id of first window whose frontmost is true
 
  45                 set targetWindow to front window
 
  46                 -- Put it on the right hand screen first
 
  47                 set position of targetWindow to {horizontalOffset, 0}
 
  48                 set position of targetWindow to {horizontalOffset, verticalPos}
 
  49                 set size of targetWindow to {width, height}
 
  50                 set position of targetWindow to {horizontalOffset, verticalPos}
 
  51                 set pos to position of targetWindow
 
  52                 if needVerticalAdjust and ((item 2 of pos) is not equal to verticalPos) then
 
  53                         set needVerticalAdjust to false
 
  54                         set verticalPos to (item 2 of pos) + desiredInitialVerticalOffset
 
  55                         set position of targetWindow to {horizontalOffset, verticalPos}
 
  57                 set verticalPos to verticalPos + height + 15
 
  59                 set current settings of selected tab of targetWindow to first settings set whose name is currentTheme
 
  62                 -- make tabs 2, 3, 4, 5
 
  63                 repeat with i from 1 to 4
 
  64                         makenewTab of me given theme:currentTheme
 
  67                 -- for each of the five tabs we've now made
 
  68                 repeat with i from 1 to 5
 
  70                         -- build the command, then execute it
 
  71                         if i is less than 5 then
 
  74                                 set myuser to "mobile"
 
  77                                 set shcmd to "syslog -w"
 
  79                                 set shcmd to "ls -1t /var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/security.log.\\*Z \\| head -1 \\| xargs  tail -100000F"
 
  81                                 set shcmd to "ls -1t /var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/security.log.\\*Z \\| head -1 \\| xargs  tail -100000F \\| egrep \"'(event|keytrace|peer|coder|engine){}|<Error>'\""
 
  83                                 set shcmd to "security item -q class=inet,sync=1 \\| grep acct \\| tail -3"
 
  86                                 -- for c in inet genp keys; do for t in "" ,tomb=1; do security item class=$c,sync=1$t; done; done | grep agrp | wc -l
 
  90                         set custom title of tab i of targetWindow to phoneColor & " " & myuser & " " & phonePort
 
  91                         set cmd to "~/bin/sshauser " & "--retry " & phonePort & " " & myuser & " " & shcmd
 
  92                         do script cmd in tab i of targetWindow
 
 105 set desiredInitialVerticalOffset to 10
 
 106 set verticalPos to -10000
 
 107 set needVerticalAdjust to true
 
 109 newPhoneTerm of me for "Red" by 11022
 
 110 newPhoneTerm of me for "Blue" by 12022
 
 111 -- newPhoneTerm of me for "Green" by 12022
 
 112 -- newPhoneTerm of me for "Cyan" by 13022
 
 113 -- newPhoneTerm of me for "Orange" by 15022
 
 114 -- newPhoneTerm of me for "Beige" by 16022
 
 115 -- newPhoneTerm of me for "Black" by 21022
 
 117 -- # Config file for ssh
 
 118 -- #UDID 79003b34516ba80b620e3d947e7da96e033bed48 johnsrediphone 10022
 
 119 -- #UDID 96476595e5d0ef7496e8ff852aedf4725647960b johnsblueiphone 11022
 
 120 -- #UDID b674745cb6d2a1616a065cddae7207f91980e95d johnsgreentouch 12022
 
 121 -- #UDID a489e67286bc2a509ef74cda67fc6696e2e1a192 johnscyanmini 13022
 
 122 -- #UDID df86edbd280fd986f1cfae1517e65acbac7188cd johnsyellowmini 14022
 
 123 -- #UDID 16d4c2e0a63083ec16e3f2ed4f21755b12deb900 johnsorangemini 15022
 
 124 -- #UDID 8b2aa30e1ead1c7c303c363216bfe44f1cb21ce6 johnsbeigeipad 16022
 
 125 -- #UDID f80b8fbf11ca6b8d692f10e9ea29dea1e57fcbdf johnswhiteipad 17022