Advertisement
devinteske

RBuild.applescript

Apr 28th, 2022
3,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env osascript
  2. # -*- tab-width: 4 -*- ;; Emacs
  3. # vi: set ts=4 sw=4 noet ft=applescript :: Vi/ViM
  4. #-
  5. ############################################################ IDENT(1)
  6. #
  7. # $Title: AppleScript to setup for an R build $
  8. # $Copyright: 2019-2022 Devin Teske. All rights reserved. $
  9. # $FrauBSD$
  10. #
  11. ############################################################ CONFIGURATION
  12.  
  13. property jenkinsDir : "src/pkgcenter-R/depend/jenkins"
  14.  
  15. ############################################################ CONFIGURATION
  16.  
  17. property columns : 2
  18. property fontSize : 13
  19. property gapX : 0
  20. property gapY : 0
  21. property marginLeft : -1440
  22. property marginTop : 23
  23.  
  24. ############################################################ GLOBALS
  25.  
  26. (* Do not change these *)
  27. property column : 0
  28. property row : 0
  29. property winSize : {}
  30. property winXinit : marginLeft
  31. property winYinit : marginTop
  32. property winX : winXinit
  33. property winY : winYinit
  34.  
  35. ############################################################ FUNCTIONS
  36.  
  37. on new(options)
  38.     set title to ""
  39.     set profile to ""
  40.     set ssh to ""
  41.     set dir to ""
  42.     try
  43.         set title to title of options
  44.     end try
  45.     try
  46.         set profile to profile of options
  47.     end try
  48.     try
  49.         set ssh to ssh of options
  50.     end try
  51.     try
  52.         set dir to dir of options
  53.     end try
  54.     set column to column + 1
  55.     if (column > columns) then
  56.         set column to 1
  57.         set row to row + 1
  58.         set winX to winXinit
  59.     end if
  60.     if (column = 1 and row > 0) then
  61.         set winY to winY + (last item of winSize) + gapY + 1
  62.     end if
  63.     tell application "Terminal"
  64.         if (ssh ≠ "") then
  65.             set currentTab to do script ("ssh -A " & ssh)
  66.         else
  67.             set currentTab to do script
  68.         end if
  69.         set theWindow to the first window
  70.         set current settings of theWindow to settings set profile
  71.         set position of theWindow to {winX, winY}
  72.         if (title ≠ "") then
  73.             set custom title of theWindow to title
  74.         end if
  75.         set font size of current settings of theWindow to fontSize
  76.         set winSize to the size of theWindow
  77.         set winX to winX + (first item of winSize) + gapX + 1
  78.         if (dir ≠ "") then
  79.             delay 0.1
  80.             do script ("cd " & dir) in currentTab
  81.         end if
  82.         delay 0.1
  83.         do script ("settitle " & "\"" & title & "\"") in currentTab
  84.     end tell
  85. end new
  86.  
  87. on new6(title)
  88.     new({title:"CentOS 6 " & title, profile:"Pro Olive", ¬
  89.         ssh:"c6buildhost", dir:jenkinsDir})
  90. end new6
  91.  
  92. on new7(title)
  93.     new({title:"CentOS 7 " & title, profile:"Blue Aerogel", ¬
  94.         ssh:"c7buildhost", dir:jenkinsDir})
  95. end new7
  96.  
  97. ############################################################ MAIN
  98.  
  99. on run
  100.     set column to 0
  101.     set row to 0
  102.     set winX to winXinit
  103.     set winY to winYinit
  104.    
  105.     tell application "Terminal" to activate
  106.     new6("R-3.1.1")
  107.     new6("R-3.3.1")
  108.     new7("R-3.1.1")
  109.     new7("R-3.3.1")
  110. end run
  111.  
  112. ################################################################################
  113. # END
  114. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement