Advertisement
Xeon3D

XSysInfo 2.0 Alpha

Jul 30th, 2011
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Debug command do not touch!
  2. --set cmd to ""
  3.  
  4. -- Defines Properties (Non volatile variables)
  5.  
  6. property ScriptVersion : "2.0alpha"
  7. property ScriptName : "XSysInfo"
  8. property ScriptHomepage : "http://xsysinfo.xeon3d.net/"
  9. property ScriptAuthor : "Xeon4D"
  10. property Contributors : "Aang"
  11. property IRCChannel : "irc://irc.wyldryde.org/#textual"
  12. property LatestVersionChecksumURL : "http://xsysinfo.xeon3d.net/files/textual/latestmd5"
  13. property ChangelogURL : "http://xsysinfo.xeon3d.net/files/textual/Changelog"
  14. property LatestScriptVersionURL : "http://xsysinfo.xeon3d.net/files/textual/latestversion"
  15. property LatestZipURLPrefix : "http://www.xeon3d.net/xsysinfo/files/textual/xsysinfo"
  16. property TemperatureAppURL : "http://xsysinfo.xeon3d.net/files/both/tempsupport.zip"
  17. property TemperatureAppChecksumURL : "http://xsysinfo.xeon3d.net/files/both/tempapp.md5"
  18.  
  19.  
  20. on textualcmd(cmd)
  21.    
  22.     -- Defines Global Variables
  23.    
  24.     global InAppPath
  25.     global AppSupportFolder
  26.     global TempAppPath
  27.     global ZippedUpdatePath
  28.    
  29.     -- Initializes Global Variables
  30.     --- Defines the folder where the script is bring run from.
  31.     set InAppPath to the quoted form of (the POSIX path of (path to application id "com.codeux.irc.textual") & "Contents/Resources/Scripts/")
  32.    
  33.     --- Defines the path to the Scripts' Folder in the Application Support in the current User's Library
  34.     set AppSupportFolder to the quoted form of (the POSIX path of (path to application support from the user domain) & "Textual/Scripts")
  35.    
  36.     --- Defines the path to the Temperature Reporting App
  37.     set TempAppPath to the quoted form of (the POSIX path of (path to application support from the user domain) & "Textual/Scripts/tempmonitor")
  38.    
  39.     --- Defines the path to where the zip file containing the update will be downloaded.
  40.     set ZippedUpdatePath to the quoted form of (the POSIX path of (path to temporary items from the user domain) & "update.zip")
  41.    
  42.     --- Defines the latest available script version
  43.     set LatestScriptVersion to do shell script "curl " & LatestScriptVersionURL
  44.    
  45.     --- Defines the latest available script version's zip file checksum
  46.     set LatestVersionChecksum to do shell script "curl " & LatestVersionChecksumURL
  47.    
  48.     --- Defines the zip file URL of the latest version
  49.     set LatestScriptZip to LatestZipURLPrefix & LatestScriptVersionURL & ".zip"
  50.    
  51.     -- Defines Formatting Stuff
  52.    
  53.     --- Initializes the Simple variable.
  54.     set Simple to ""
  55.    
  56.     ---  Colors
  57.     set CBlack to (ASCII character 3) & "01"
  58.     set CNBlue to (ASCII character 3) & "02"
  59.     set CGreen to (ASCII character 3) & "03"
  60.     set CRed to (ASCII character 3) & "04"
  61.     set CBrown to (ASCII character 3) & "05"
  62.     set CPurple to (ASCII character 3) & "06"
  63.     set COrange to (ASCII character 3) & "07"
  64.     set CYellow to (ASCII character 3) & "08"
  65.     set CLGreen to (ASCII character 3) & "09"
  66.     set CTeal to (ASCII character 3) & "10"
  67.     set CCyan to (ASCII character 3) & "11"
  68.     set CBlue to (ASCII character 3) & "12"
  69.     set CPink to (ASCII character 3) & "13"
  70.     set CGrey to (ASCII character 3) & "14"
  71.     set CLGrey to (ASCII character 3) & "15"
  72.     set CWhite to (ASCII character 3)
  73.     set NoColor to (ASCII character 0)
  74.    
  75.     --- Formatting
  76.     set FBold to (ASCII character 2)
  77.     set FItalic to (ASCII character 1)
  78.    
  79.     -- Defines the Bars' Colors
  80.     set UsedColor to CGreen
  81.     set FreeColor to CRed
  82.     set SeparatorColor to NoColor
  83.    
  84.     -- Removes formatting from output.
  85.     if (cmd contains "simple") or (Simple is true or Simple is "True") then
  86.         set UsedColor to ""
  87.         set FreeColor to ""
  88.         set CWhite to ""
  89.         set FBold to ""
  90.         set FItalic to ""
  91.     end if
  92.    
  93.     -- Trying to read user set options, and if not write the default values for them.
  94.     -- This regards showing the final dot/separator.
  95.     try
  96.         set HideFinalDot to do shell script "defaults read xeon3d.xsysinfo hidefinaldot"
  97.     on error
  98.         try
  99.             do shell script ("defaults write xeon3d.xsysinfo hidefinaldot True")
  100.             set HideFinalDot to "True"
  101.         on error
  102.             set msg to "/echo There was an error writing defaults hidefinaldot"
  103.             return msg
  104.         end try
  105.     end try
  106.     -- This regards if it takes into account every mounted disk/net share or just the startupdisk
  107.     try
  108.         set ShowAllDisks to do shell script "defaults read xeon3d.xsysinfo alldisks"
  109.     on error
  110.         try
  111.             do shell script ("defaults write xeon3d.xsysinfo alldisks False")
  112.             set ShowAllDisks to "False"
  113.         on error
  114.             set msg to "/echo There was an error with the ShowAllDisks variable"
  115.             return msg
  116.         end try
  117.     end try
  118.     -- This regards if the Textual Build version is shown or not
  119.     try
  120.         set ViewTextualBuild to do shell script "defaults read xeon3d.xsysinfo viewtextualbuild"
  121.     on error
  122.         try
  123.             do shell script ("defaults write xeon3d.xsysinfo viewtextualbuild False")
  124.             set ViewTextualBuild to "False"
  125.         on error
  126.             set msg to "/echo There was an error with the ViewTextualBuild variable"
  127.             return msg
  128.         end try
  129.     end try
  130.     -- This regards if the script's output is formatted or not
  131.     try
  132.         set Simple to do shell script "defaults read xeon3d.xsysinfo simple"
  133.     on error
  134.         try
  135.             do shell script ("defaults write xeon3d.xsysinfo simple False")
  136.             set Simple to "False"
  137.         on error
  138.             set msg to "/echo There was an error with the Simple variable"
  139.             return msg
  140.         end try
  141.     end try
  142.    
  143.     -- This regards if the temperatures are shown by default or not
  144.     try
  145.         set EnableTemps to do shell script "defaults read xeon3d.xsysinfo showtemps"
  146.     on error
  147.         try
  148.             do shell script ("defaults write xeon3d.xsysinfo showtemps False")
  149.             set EnableTemps to "False"
  150.         on error
  151.             set msg to "/echo There was an error with the EnableTemps variable"
  152.             return msg
  153.         end try
  154.     end try
  155.    
  156.     -- This regards if the script should warn the user about an available update at runtime.
  157.     try
  158.         set AutomaticUpdateChecker to do shell script "defaults read xeon3d.xsysinfo autocheckupdate"
  159.     on error
  160.         try
  161.             do shell script ("defaults write xeon3d.xsysinfo autocheckupdate False")
  162.             set AutomaticUpdateChecker to "False"
  163.         on error
  164.             set msg to "/echo There was an error with the AutomaticUpdateChecker variable"
  165.             return msg
  166.         end try
  167.     end try
  168.    
  169.    
  170.     if cmd is "" or cmd is "simple" then --Default output when no options or just "simple" is supplied at runtime (edit to taste)
  171.         set ViewMac to true
  172.         set ViewCPU to true
  173.         set ViewCurrentCPUSpeed to false
  174.         set ViewCap to false
  175.         set ViewCache to false
  176.         set ViewFSB to false
  177.         if EnableTemps is "True" then
  178.             set ViewTemp to true
  179.         else
  180.             set ViewTemp to false
  181.         end if
  182.         set ViewRam to true
  183.         set ViewBars to true
  184.         set ViewDisk to true
  185.         set ViewDisplay to true
  186.         set ViewGFXBus to false
  187.         set ViewResolutions to true
  188.         set ViewAudio to false
  189.         set ViewPower to true
  190.         set ViewOSXVersion to true
  191.         set ViewOSXArch to true
  192.         set ViewOSXBuild to true
  193.         set ViewKernel to false
  194.         set ViewKernelBuild to false
  195.         set ViewUptime to true
  196.         set ViewClient to true
  197.         set ViewScriptVersion to true
  198.        
  199.         --The start of the script (edit below this and I wont help you) - MOST THINGS WILL BREAK IF YOU CHANGE ANYTHING BELOW THIS.            
  200.        
  201.     else --Toggled output
  202.         set ViewMac to (cmd contains "mac")
  203.         set ViewCPU to (cmd contains "cpu")
  204.         if ViewCPU then
  205.             set ViewCurrentCPUSpeed to (cmd contains "speed")
  206.             set ViewCap to (cmd contains "cap")
  207.             set ViewCache to (cmd contains "cache")
  208.         end if
  209.         set ViewFSB to (cmd contains "fsb")
  210.         set ViewTemp to (cmd contains "temp")
  211.         set ViewRam to (cmd contains "ram")
  212.         set ViewBars to (cmd contains "bar")
  213.         set ViewDisk to (cmd contains "disk")
  214.         set ViewDisplay to (cmd contains "gpu" or cmd contains "graphics" or cmd contains "video")
  215.         set ViewGFXBus to (cmd contains "gpu" or cmd contains "graphics" or cmd contains "video" and cmd contains "bus")
  216.         set ViewResolutions to (cmd contains "gpu" or cmd contains "graphics" or cmd contains "video" and cmd contains "res")
  217.         set ViewAudio to (cmd contains "audio" or cmd contains "sound")
  218.         set ViewPower to (cmd contains "power")
  219.         set ViewOSXVersion to (cmd contains "osx")
  220.         set ViewOSXBuild to (cmd contains "osx" and cmd contains "build")
  221.         set ViewOSXArch to (cmd contains "osx" and cmd contains "arch")
  222.         set ViewKernel to (cmd contains "kernel")
  223.         set ViewKernelBuildTag to (cmd contains "kernel" and cmd contains "tag")
  224.         set ViewUptime to (cmd contains "uptime")
  225.         set ViewClient to (cmd contains "client")
  226.         set ViewScriptVersion to (cmd contains "script")
  227.        
  228.        
  229.         if cmd is "version" then
  230.             if ScriptVersion contains "beta" or ScriptVersion contains "alpha" then
  231.                 set msg to "Script Version: " & ScriptName & space & ScriptVersion & " for Textual by " & ScriptAuthor & " (" & IRCChannel & "). For Beta-Testers Only."
  232.             else
  233.                 set msg to "Script Version: " & ScriptName & space & ScriptVersion & " for Textual by " & ScriptAuthor & ". Get it @ " & ScriptHomepage
  234.             end if
  235.             return msg
  236.         end if
  237.     end if
  238.    
  239.     if cmd is "options" then
  240.         set msg to "/echo Possible Options:" & nl & ¬
  241.             "/echo To change an option type '/xsysinfo <option name> toggle'. Example: /xsysinfo simple toggle " & nl & ¬
  242.             "/echo • hidefinaldot - Defines if the final dot (separator) is shown." & FBold & " - Current Status: " & FBold & CRed & HideFinalDot & nl & ¬
  243.             "/echo • alldisks - Defines if the script considers every mounted disk / net share as available disk space or not." & FBold & " - Current Status: " & FBold & CRed & allDisks & nl & ¬
  244.             "/echo • viewtextualbuild - Defines if the Textual Build version is shown." & FBold & " - Current Status: " & FBold & CRed & ViewTextualBuild & nl & ¬
  245.             "/echo • simple - Defines if the formatting is removed from the output of the script." & FBold & " - Current Status: " & FBold & CRed & Simple & nl & ¬
  246.             "/echo • showtemps - Defines if the script shows temperatures." & FBold & " - Current Status: " & FBold & CRed & showtemps & nl & ¬
  247.             "/echo • autocheckupdate - Defines if the script checks for updates at each time it runs." & FBold & " - Current Status: " & FBold & CRed & autocheckupdate
  248.         return msg
  249.     end if
  250.    
  251.     if cmd is "hidefinaldot" then
  252.         if HideFinalDot is "True" then
  253.             set msg to "/echo The last dot (separator) is currently " & FBold & "NOT" & FBold & " being shown. To change this type '/xsysinfo hidefinaldot toggle'"
  254.             return msg
  255.         else if HideFinalDot is "False" then
  256.             set msg to "/echo The last dot (separator) is currently " & FBold & "BEING" & FBold & " shown. To change this type '/xsysinfo hidefinaldot toggle'"
  257.             return msg
  258.         end if
  259.     end if
  260.    
  261.     if cmd is "hidefinaldot toggle" then
  262.         if HideFinalDot is "True" then
  263.             do shell script "defaults write xeon3d.xsysinfo hidefinaldot False"
  264.             return "/echo The final dot (separator) is now being SHOWN!"
  265.         else if HideFinalDot is "False" then
  266.             do shell script "defaults write xeon3d.xsysinfo hidefinaldot True"
  267.             return "/echo The final dot (separator) is now being HIDDEN!"
  268.         end if
  269.     end if
  270.    
  271.     if cmd is "alldisks" then
  272.         if ShowAllDisks is "True" then
  273.             set msg to "/echo The script will use " & FBold & "All mounted disks" & FBold & ". To change this type '/xsysinfo alldisks toggle'"
  274.             return msg
  275.         else if ShowAllDisks is "False" then
  276.             set msg to "/echo The script will use " & FBold & "the Startup disk only" & FBold & ". To change this type '/xsysinfo alldisks toggle'"
  277.             return msg
  278.         end if
  279.     end if
  280.    
  281.     if cmd is "alldisks toggle" then
  282.         if ShowAllDisks is "True" then
  283.             do shell script "defaults write xeon3d.xsysinfo alldisks False"
  284.             return "/echo The script will now use the Startup disk only!"
  285.         else if ShowAllDisks is "False" then
  286.             do shell script "defaults write xeon3d.xsysinfo alldisks True"
  287.             return "/echo The script will now use all mounted disks!"
  288.         end if
  289.     end if
  290.    
  291.     if cmd is "viewtextualbuild" then
  292.         if ViewTextualBuild is "True" then
  293.             set msg to "/echo The script will " & FBold & "show" & FBold & " Textual's Build Version. To change this type '/xsysinfo ViewTextualBuild toggle'"
  294.             return msg
  295.         else if ViewTextualBuild is "False" then
  296.             set msg to "/echo The script " & FBold & "won't show" & FBold & " Textual's Build Version. To change this type '/xsysinfo ViewTextualBuild toggle'"
  297.             return msg
  298.         end if
  299.     end if
  300.    
  301.     if cmd is "viewtextualbuild toggle" then
  302.         if ViewTextualBuild is "True" then
  303.             do shell script "defaults write xeon3d.xsysinfo viewtextualbuild False"
  304.             return "/echo The script " & FBold & "won't show" & FBold & " Textual's Build Version."
  305.         else
  306.             do shell script "defaults write xeon3d.xsysinfo viewtextualbuild True"
  307.             return "/echo The script will " & FBold & "show" & FBold & " Textual's Build Version."
  308.         end if
  309.     end if
  310.    
  311.     if cmd is "simple" then
  312.         if Simple is "True" then
  313.             set msg to "/echo The script " & FBold & "will remove" & FBold & " the formatting from the output. To change this type '/xsysinfo simple toggle'"
  314.             return msg
  315.         else if Simple is "False" then
  316.             set msg to "/echo The script " & FBold & "won't remove" & FBold & " the formatting from the output. To change this type '/xsysinfo simple toggle'"
  317.             return msg
  318.         end if
  319.     end if
  320.    
  321.     if cmd is "simple toggle" then
  322.         if Simple is "True" then
  323.             do shell script "defaults write xeon3d.xsysinfo simple False"
  324.             return "/echo The script " & FBold & "won't remove" & FBold & " the formatting from the output."
  325.         else if Simple is "False" then
  326.             do shell script "defaults write xeon3d.xsysinfo simple True"
  327.             return "/echo The script " & FBold & "will remove" & FBold & " the formatting from the output."
  328.         end if
  329.     end if
  330.    
  331.     if cmd is "showtemps" then
  332.         if showtemps is "True" then
  333.             set msg to "/echo The script will " & FBold & "show" & FBold & " temperatures. To change this type '/xsysinfo showtemps toggle'"
  334.             return msg
  335.         else if showtemps is "False" then
  336.             set msg to "/echo The script will " & FBold & "not show" & FBold & "  temperatures. To change this type '/xsysinfo showtemps toggle'"
  337.             return msg
  338.         end if
  339.     end if
  340.    
  341.     if cmd is "showtemps toggle" then
  342.         if showtemps is "True" then
  343.             do shell script "defaults write xeon3d.xsysinfo showtemps False"
  344.             return "/echo The script will now " & FBold & "not show" & FBold & " temperatures."
  345.         else if showtemps is "False" then
  346.             do shell script "defaults write xeon3d.xsysinfo showtemps True"
  347.             return "/echo The script will now " & FBold & "show" & FBold & " temperatures."
  348.         end if
  349.     end if
  350.    
  351.    
  352.     if cmd is "autocheckupdate" then
  353.         if AutomaticUpdateChecker is "True" then
  354.             set msg to "/echo The script will " & FBold & "check" & FBold & " for updates at runtime. To change this type '/xsysinfo autocheckupdate toggle'"
  355.             return msg
  356.         else if AutomaticUpdateChecker is "False" then
  357.             set msg to "/echo The script will " & FBold & "not check" & FBold & " for updates at runtime. To change this type '/xsysinfo autocheckupdate toggle'"
  358.             return msg
  359.         end if
  360.     end if
  361.    
  362.     if cmd is "autocheckupdate toggle" then
  363.         if AutomaticUpdateChecker is "True" then
  364.             do shell script "defaults write xeon3d.xsysinfo autocheckupdate False"
  365.             return "/echo The script " & FBold & "will not check" & FBold & " for updates at runtime."
  366.         else if AutomaticUpdateChecker is "False" then
  367.             do shell script "defaults write xeon3d.xsysinfo autocheckupdate True"
  368.             return "/echo The script " & FBold & "will check" & FBold & " for updates at runtime."
  369.         end if
  370.     end if
  371.    
  372.     if cmd is "installtemp" then
  373.         set tempappMD5 to do shell script "curl http://www.xeon3d.net/xsysinfo/files/both/tempapp.md5"
  374.         set tempappURL to "http://www.xeon3d.net/xsysinfo/files/both/tempsupport.zip"
  375.         do shell script "rm -f " & qtempapppath
  376.         set DownloadNewVersion to do shell script "curl -C - " & tempappURL & " -o /tmp/tempsupport.zip"
  377.         if tempappMD5 is not (do shell script "md5 -q /tmp/tempsupport.zip") then
  378.             if tempappMD5 contains "DOCTYPE" then
  379.                 return "/debug echo Error installing Temperature Support. Please try again later or download manually from here: http://xsysinfo.xeon3d.net/files/both/tempsupport.zip " & nl & "/debug echo Cannot access the tempappMD5 file."
  380.             end if
  381.             return "/debug echo Error installing Temperature Support. Please try again later or download download manually from here: http://xsysinfo.xeon3d.net/files/both/tempsupport.zip " & nl & "/debug echo Online MD5: " & LatestVersionMD5 & nl & "/debug echo Local MD5: " & (do shell script "md5 -q /tmp/tempsupport.zip")
  382.         end if
  383.         set InstallUpdateResult to do shell script "unzip -o /tmp/tempsupport.zip -d " & qaspath
  384.         -- Debug command!
  385.         -- return InstallUpdateResult
  386.         if InstallUpdateResult contains "inflating:" then
  387.             set ResultMessage to "/echo Successefully installed Temperature Support!"
  388.             return ResultMessage
  389.         else if InstallUpdateResult contains "cannot" then
  390.             set ResultMessage to "/echo Error installing Temperature Support! Try again later!"
  391.             return ResultMessage
  392.         end if
  393.     end if
  394.    
  395.     -- Update "engine" 2.2
  396.     if cmd is "update" then
  397.         if LatestScriptVersion contains "DOCTYPE" then
  398.             return "/debug echo Error getting the latest" & ScriptName & " version number. Please try again later or download newest version here: http://xsysinfo.xeon3d.net "
  399.         end if
  400.         if LatestScriptVersion is greater than ScriptVersion then
  401.             do shell script "rm -f " & ZippedUpdatePath
  402.             set DownloadNewVersion to do shell script "curl -C - " & LatestScriptZip & " -o " & ZippedUpdatePath
  403.             if LatestVersionChecksum is not (do shell script "md5 -q " & ZippedUpdatePath) then
  404.                 if LatestVersionChecksum contains "DOCTYPE" then
  405.                     return "/debug echo Error getting the online checksum for the latest " & ScriptName & "version. Please try again later or download newest version here: http://xsysinfo.xeon3d.net "
  406.                 end if
  407.                 return "/debug echo Error updating XSysInfo. Please try again later or download newest version here: http://xsysinfo.xeon3d.net " & nl & "/debug echo Checksum's don't match: Online MD5: " & LatestVersionChecksum & nl & "/debug echo Local MD5: " & (do shell script "md5 -q " & ZippedUpdatePath)
  408.             end if
  409.             set InstallUpdateResult to do shell script "unzip -o " & ZippedUpdatePath & " -d " & AppSupportFolder
  410.             -- Debug command!
  411.             -- return InstallUpdateResult
  412.             if InstallUpdateResult contains "inflating:" then
  413.                 set ResultMessage to "/echo Successefully updated XSysInfo to version " & LatestScriptVersion & " from " & ScriptVersion & "." & nl & "/echo Changelog: " & ChangelogURL
  414.                 return ResultMessage
  415.             else if InstallUpdateResult contains "cannot" then
  416.                 set ResultMessage to "/echo Error extracting XSysInfo."
  417.                 return ResultMessage
  418.             end if
  419.         else if LatestScriptVersion is equal to ScriptVersion then
  420.             set ResultMessage to "/echo XSysInfo is already up to date. (Your script version: " & ScriptVersion & "; Latest released script version: " & LatestScriptVersion & ")"
  421.             return ResultMessage
  422.         else if ScriptVersion is greater than LatestScriptVersion then
  423.             set ResultMessage to "/echo Your copy of XSysInfo is newer than the last released version. (Your script version: " & ScriptVersion & "; Latest released script version: " & LatestScriptVersion & ")"
  424.             return ResultMessage
  425.         end if
  426.     end if
  427.    
  428.    
  429.     if cmd is "refresh" then
  430.         tell application "Finder"
  431.             if exists POSIX file "/tmp/SPHardwareDataType.txt" then
  432.                 do shell script "rm -rf /tmp/SPHardwareDataType.txt"
  433.             end if
  434.             if exists POSIX file "/tmp/SPDisplaysDataType.txt" then
  435.                 do shell script "rm -rf /tmp/SPDisplaysDataType.txt"
  436.             end if
  437.         end tell
  438.     end if
  439.    
  440.     if cmd is "help" then
  441.         set helpmsg to "/echo " & FBold & "Usage:" & FBold & " /xsysinfo [labels] [simple]" & nl & ¬
  442.             "/echo If run without arguments, it'll show a predefined set of system details that can be customized by typing '/xsysinfo options'" & nl & ¬
  443.             "/echo Possible labels:" & nl & "/echo mac, cpu, speed, cap, cache, fsb, temp, ram, bar, mem, hd, gpu, res, audio, power, osxversion, osxbuild, kernel, kernarch, kernbuild, uptime, client." & nl & ¬
  444.             "/echo There are also some special labels: 'about' shows some info about the script; " & nl & ¬
  445.             "/echo The 'simple' label makes the script output without any formatting (colors, bold, etc...); " & nl & ¬
  446.             "/echo The 'update' label updates the script and the 'version' label displays the current version."
  447.         return helpmsg
  448.     end if
  449.    
  450.    
  451.     if cmd is "about" then
  452.         set helpmsg to "/echo XSysInfo " & currentversion & " - A System Information Script for the Textual IRC Client" & nl & ¬
  453.             "/echo Homepage: http://xsysinfo.xeon3d.net / http://www.xeon3d.net" & nl & ¬
  454.             "/echo Coded by Marcos Alves - xeon3d@xeon3d.net - Xeon3D @ irc://irc.wyldryde.org/#textual" & nl & ¬
  455.             "/echo Loosely based on KSysInfo for Linkinus by KanadaKid" & nl & ¬
  456.             "/echo Some code/fixes by Aang / ePirat @ irc://irc.wyldryde.org/#textual" & nl & ¬
  457.             "/echo Many thanks for the #textual users for testing/using it and reporting bugs. Keep 'em coming!"
  458.         return helpmsg
  459.     end if
  460.    
  461.     tell application "Finder"
  462.        
  463.         set msg to ""
  464.        
  465.         --debug command
  466.         --set viewtemp to true
  467.        
  468.        
  469.         if AutomaticUpdateChecker is "True" then
  470.             if LatestScriptVersion is greater than ScriptVersion then
  471.                 set msg to "/echo Info: XSysInfo " & FBold & LatestScriptVersion & FBold & " has been released. You're currently running XSysInfo " & FBold & ScriptVersion & FBold & "." & nl & "/echo To update to the latest version type '/xsysinfo update' (without the quotes). To disable this check type '/xsysinfo autocheckupdate'." & nl & msg
  472.             end if
  473.         end if
  474.        
  475.         if exists POSIX file "/tmp/SPHardwareDataType.txt" then
  476.         else
  477.             set listDataTypes to do shell script "system_profiler -listdatatypes"
  478.             if listDataTypes contains "SPHardwareDataType" then
  479.                 do shell script "system_profiler SPHardwareDataType > /tmp/SPHardwareDataType.txt"
  480.             else
  481.                 do shell script "system_profiler > /tmp/SPHardwareDataType.txt"
  482.             end if
  483.         end if
  484.        
  485.         --Temperature support
  486.         if ViewTemp is true then
  487.             -- return quoted form of tempapppath
  488.             try
  489.                 set checkfortempsupport to (do shell script "if [ -f " & TempAppPath & " ] ; then exit 0 ; else exit 1 ; fi")
  490.                 set tempsupportinstalled to true
  491.             on error theError
  492.                 set tempsupportinstalled to false
  493.             end try
  494.             if tempsupportinstalled is true then
  495.                 set cpuresult to do shell script TempAppPath & " -l -a -c | grep 'SMC CPU A PROXIMITY' | awk '{print $5}'"
  496.                 set hdresult to do shell script TempAppPath & " -l -a -c | grep 'SMART Disk' | head -n1 | awk '{print $5}'"
  497.             else
  498.                 return "/echo Temperature Support is not installed. Please run " & FBold & "/xsysinfo installtemp" & FBold & " to install it."
  499.             end if
  500.             --Debug Command
  501.             --set CPUResult to "68"
  502.         end if
  503.        
  504.         --Mac Model
  505.         if ViewMac is true then
  506.             set machineName to do shell script "sysctl -n hw.model"
  507.            
  508.             if machineName is "iMac4,1" then
  509.                 set MacModel to "iMac (Early 2006)"
  510.             else if machineName is "iMac4,2" then
  511.                 set MacModel to "iMac (Mid 2006)"
  512.             else if machineName is "iMac5,2" then
  513.                 set MacModel to "iMac (Late 2006 CD)"
  514.             else if machineName is "iMac5,1" then
  515.                 set MacModel to "iMac (Late 2006)"
  516.             else if machineName is "iMac6,1" then
  517.                 set MacModel to "iMac (24-inch Late 2006)"
  518.             else if machineName is "iMac7,1" then
  519.                 set MacModel to "iMac (Mid 2007)"
  520.             else if machineName is "iMac8,1" then
  521.                 set MacModel to "iMac (Early 2008)"
  522.             else if machineName is "iMac9,1" then
  523.                 set MacModel to "iMac (2009)"
  524.             else if machineName is "iMac10,1" then
  525.                 set MacModel to "iMac (Late 2009 C2D)"
  526.             else if machineName is "iMac11,1" then
  527.                 set MacModel to "iMac (Late 2009 Core iX)"
  528.             else if machineName is "iMac11,2" then
  529.                 set MacModel to "iMac (Mid 2010 21.5')"
  530.             else if machineName is "iMac11,3" then
  531.                 set MacModel to "iMac (Mid 2010 27')"
  532.             else if machineName is "iMac12,1" then
  533.                 set MacModel to "iMac (Mid 2011 21.5')"
  534.             else if machineName is "iMac12,2" then
  535.                 set MacModel to "iMac (Mid 2011 27')"
  536.                 -- Mac Minis
  537.             else if machineName is "Macmini1,1" then
  538.                 set MacModel to "Mac Mini (2006)"
  539.             else if machineName is "Macmini2,1" then
  540.                 set MacModel to "Mac Mini (2007)"
  541.             else if machineName is "Macmini3,1" then
  542.                 set MacModel to "Mac Mini (2009)"
  543.             else if machineName is "Macmini4,1" then
  544.                 set MacModel to "Mac Mini (2010)"
  545.                 -- Mac Pros
  546.             else if machineName is "MacPro1,1" then
  547.                 set MacModel to "Mac Pro (Original)"
  548.             else if machineName is "MacPro2,1" then
  549.                 set MacModel to "Mac Pro (2007 8-core)"
  550.             else if machineName is "MacPro3,1" then
  551.                 set MacModel to "Mac Pro (Early 2008)"
  552.             else if machineName is "MacPro4,1" then
  553.                 set MacModel to "Mac Pro (Early 2009)"
  554.             else if machineName is "MacPro5,1" then
  555.                 set MacModel to "Mac Pro (Mid 2010)"
  556.                 -- MacBooks
  557.             else if machineName is "MacBook1,1" then
  558.                 set MacModel to "MacBook (Original 2006)"
  559.             else if machineName is "MacBook2,1" then
  560.                 set MacModel to "MacBook (2006/7)"
  561.             else if machineName is "MacBook3,1" then
  562.                 set MacModel to "MacBook (Late 2007)"
  563.             else if machineName is "MacBook4,1" then
  564.                 set MacModel to "MacBook (2008)"
  565.             else if machineName is "MacBook5,1" then
  566.                 set MacModel to "MacBook (Late 2008, Aluminum)"
  567.             else if machineName is "MacBook5,2" then
  568.                 set MacModel to "MacBook (2009)"
  569.             else if machineName is "MacBook6,1" then
  570.                 set MacModel to "MacBook (Late 2009)"
  571.             else if machineName is "MacBook7,1" then
  572.                 set MacModel to "MacBook (Mid 2010)"
  573.                 --MacBook Airs
  574.             else if machineName is "MacBookAir1,1" then
  575.                 set MacModel to "MacBook Air (Original)"
  576.             else if machineName is "MacBookAir2,1" then
  577.                 set MacModel to "MacBook Air (2008/9)"
  578.             else if machineName is "MacBookAir3,1" then
  579.                 set MacModel to "MacBook Air (Late 2010, 11')"
  580.             else if machineName is "MacBookAir3,2" then
  581.                 set MacModel to "MacBook Air (Late 2010, 13')"
  582.                 --MacBook Pros
  583.             else if machineName is "MacBookPro1,1" then
  584.                 set MacModel to "MacBook Pro (Original)"
  585.             else if machineName is "MacBookPro1,2" then
  586.                 set MacModel to "MacBook Pro (Original 17')"
  587.             else if machineName is "MacBookPro2,2" then
  588.                 set MacModel to "MacBook Pro (C2D 15')"
  589.             else if machineName is "MacBookPro2,1" then
  590.                 set MacModel to "MacBook Pro (C2D 17')"
  591.             else if machineName is "MacBookPro3,1" then
  592.                 set MacModel to "MacBook Pro (2007)"
  593.             else if machineName is "MacBookPro4,1" then
  594.                 set MacModel to "MacBook Pro (2008)"
  595.             else if machineName is "MacBookPro5,1" then
  596.                 set MacModel to "MacBook Pro (Late 2008)"
  597.             else if machineName is "MacBookPro5,5" then
  598.                 set MacModel to "MacBook Pro (Mid 2009, 13')"
  599.             else if machineName is "MacBookPro5,4" then
  600.                 set MacModel to "MacBook Pro (Mid 2009, 15')"
  601.             else if machineName is "MacBookPro5,3" then
  602.                 set MacModel to "MacBook Pro (Mid 2009, 15')"
  603.             else if machineName is "MacBookPro5,2" then
  604.                 set MacModel to "MacBook Pro (2009, 17')"
  605.             else if machineName is "MacBookPro7,1" then
  606.                 set MacModel to "MacBook Pro (Mid 2010, 13')"
  607.             else if machineName is "MacBookPro6,2" then
  608.                 set MacModel to "MacBook Pro (Mid 2010, 15')"
  609.             else if machineName is "MacBookPro6,1" then
  610.                 set MacModel to "MacBook Pro (Mid 2010, 17')"
  611.             else if machineName is "MacBookPro8,1" then
  612.                 set MacModel to "MacBook Pro (Early 2011, 13')"
  613.             else if machineName is "MacBookPro8,2" then
  614.                 set MacModel to "MacBook Pro (Early 2011, 15')"
  615.             else if machineName is "MacBookPro8,3" then
  616.                 set MacModel to "MacBook Pro (Early 2011, 17')"
  617.                 -- xServes
  618.             else if machineName is "Xserve1,1" then
  619.                 set MacModel to "Xserve (Original)"
  620.             else if machineName is "Xserve2,1" then
  621.                 set MacModel to "Xserve (Early 2008)"
  622.             else if machineName is "Xserve3,1" then
  623.                 set MacModel to "Xserve (Early 2009)"
  624.             else if machineName is "" then
  625.                 set MacModel to "Unknown"
  626.             else
  627.                 set MacModel to machineName
  628.             end if
  629.             set msg to msg & FBold & "Mac: " & FBold & MacModel & " • "
  630.         end if
  631.        
  632.        
  633.         --CPU Info
  634.         if ViewCPU is true then
  635.             set corecheck to do shell script "sysctl -n machdep.cpu.cores_per_package"
  636.             set msg to msg & FBold & "CPU: " & FBold
  637.             set cputype to do shell script "sysctl machdep.cpu.brand_string | awk '{ print $2,$3,$4,$5,$6,$7,$8,$9 }'"
  638.             repeat
  639.                 if cputype contains "@ " then
  640.                     set AppleScript's text item delimiters to "@ "
  641.                     set cpu1 to text item 1 of cputype
  642.                     set cpu2 to text items 2 thru end of cputype
  643.                     set cputype to cpu1 & cpu2
  644.                 else
  645.                     exit repeat
  646.                 end if
  647.             end repeat
  648.             repeat
  649.                 if cputype contains "(R)" then
  650.                     set AppleScript's text item delimiters to "(R)"
  651.                     set cpu1 to text item 1 of cputype
  652.                     set cpu2 to text items 2 thru end of cputype
  653.                     set cputype to cpu1 & cpu2
  654.                 else
  655.                     exit repeat
  656.                 end if
  657.             end repeat
  658.             repeat
  659.                 if cputype contains "Processor " then
  660.                     set AppleScript's text item delimiters to "Processor "
  661.                     set cpu1 to text item 1 of cputype
  662.                     set cpu2 to text items 2 thru end of cputype
  663.                     set cputype to cpu1 & cpu2
  664.                 else
  665.                     exit repeat
  666.                 end if
  667.             end repeat
  668.             repeat
  669.                 if cputype contains "CPU " then
  670.                     set AppleScript's text item delimiters to "CPU "
  671.                     set cpu1 to text item 1 of cputype
  672.                     set cpu2 to text items 2 thru end of cputype
  673.                     set cputype to cpu1 & cpu2
  674.                 else
  675.                     exit repeat
  676.                 end if
  677.             end repeat
  678.             repeat
  679.                 if cputype contains "(TM)" then
  680.                     set AppleScript's text item delimiters to "(TM)"
  681.                     set cpu1 to text item 1 of cputype
  682.                     set cpu2 to text items 2 thru end of cputype
  683.                     set cputype to cpu1 & cpu2
  684.                 else
  685.                     exit repeat
  686.                 end if
  687.             end repeat
  688.             if cputype contains "GHz" then
  689.                 set AppleScript's text item delimiters to "GHz"
  690.                 set cputype to text item 1 of cputype & "GHz"
  691.             end if
  692.             set msg to msg & cputype
  693.            
  694.             --Current CPU Speed
  695.             if ViewCurrentCPUSpeed is true then
  696.                 set cpufreq to do shell script "sysctl -n hw.cpufrequency"
  697.                 if cpufreq / 1000000990 then
  698.                     set temp to (cpufreq / 100000000) / 10
  699.                     set msg to msg & " @ " & "" & (round temp * 100) / 100 & "GHz"
  700.                 else
  701.                     set temp to (cpufreq / 1000000)
  702.                     set msg to msg & " @ " & "" & (round temp * 100) / 100 & "MHz"
  703.                 end if
  704.             end if
  705.            
  706.            
  707.             --CPU Features
  708.             if ViewCap is true then
  709.                 set features to do shell script "sysctl -n machdep.cpu.features"
  710.                 set extfeatures to do shell script "sysctl -n machdep.cpu.extfeatures"
  711.                 set logicalcheck to do shell script "sysctl -n machdep.cpu.logical_per_package"
  712.                 set msg to msg & " ["
  713.                 if features contains "SSE3" then
  714.                     set msg to msg & "SSE3"
  715.                 else
  716.                     set msg to msg & "SSE2"
  717.                 end if
  718.                 if features contains "SSSE3" then
  719.                     set msg to msg & "" & "/SSSE3"
  720.                 end if
  721.                 if features contains "PAE" then
  722.                     set msg to msg & "" & "/PAE"
  723.                 end if
  724.                 if extfeatures contains "XD" then
  725.                     if cputype contains "AMD" then
  726.                         set msg to msg & "" & "/NX"
  727.                     else
  728.                         set msg to msg & "" & "/XD"
  729.                     end if
  730.                 end if
  731.                 if features contains "MMX" then
  732.                     if cputype contains "AMD" then
  733.                         set msg to msg & "" & "/3DNow!"
  734.                     end if
  735.                 end if
  736.                 if features contains "EST" then
  737.                     if cputype contains "AMD" then
  738.                         set msg to msg & "" & "/PowerNow!"
  739.                     else
  740.                         set msg to msg & "" & "/EST"
  741.                     end if
  742.                 end if
  743.                 if features contains "VMX" then
  744.                     set msg to msg & "" & "/VMX"
  745.                 end if
  746.                 if extfeatures contains "EM64T" then
  747.                     if cputype contains "AMD" then
  748.                         set msg to msg & "" & "/AMD64"
  749.                     else
  750.                         set msg to msg & "" & "/EM64T"
  751.                     end if
  752.                 end if
  753.                 if logicalcheck contains 2 then
  754.                     if corecheck contains 0 then
  755.                         if cputype contains "AMD" then
  756.                             set msg to msg & "" & "/DualCore"
  757.                         else
  758.                             set msg to msg & "" & "/HTT"
  759.                         end if
  760.                     end if
  761.                     if corecheck contains 1 then
  762.                         if cputype contains "AMD" then
  763.                             set msg to msg & "" & "/DualCore"
  764.                         else
  765.                             set msg to msg & "" & "/HTT"
  766.                         end if
  767.                     end if
  768.                     if corecheck contains 2 then
  769.                         if cputype does not contain "Intel Pentium M" then
  770.                             set msg to msg & "" & "/DualCore"
  771.                         end if
  772.                     end if
  773.                 end if
  774.                 if corecheck is "4" then
  775.                     set msg to msg & "" & "/QuadCore"
  776.                 end if
  777.                 if corecheck contains 6 then
  778.                     set msg to msg & "" & "/SixCore"
  779.                 end if
  780.                 if corecheck contains 8 then
  781.                     set msg to msg & "" & "/OctoCore"
  782.                 end if
  783.                 set msg to msg & "]"
  784.             end if
  785.            
  786.            
  787.            
  788.            
  789.             --CPU Temps
  790.             if ViewTemp is true then
  791.                 if cpuresult is "" then
  792.                     set msg to msg
  793.                 else
  794.                     set msg to msg & FBold & " Temp: " & FBold & cpuresult & "ºC"
  795.                 end if
  796.             else
  797.                 set msg to msg
  798.             end if
  799.             set msg to msg & " • "
  800.         end if
  801.        
  802.         -- Note: All the above are inside the ViewCPU block.
  803.        
  804.         --L2 Cache
  805.         if ViewCache is true then
  806.             set coreicheck to do shell script "sysctl machdep.cpu.brand_string"
  807.             if coreicheck contains "Core(TM) i" then
  808.                 set cpucache to do shell script "sysctl -n hw.l3cachesize"
  809.                 set msg to msg & FBold & "L3: " & FBold & (round (cpucache / 1024 / 1024)) & "MiB • "
  810.             else
  811.                 set cpucache to do shell script "sysctl -n hw.l2cachesize"
  812.                 set msg to msg & FBold & "L2: " & FBold & (round (cpucache / 1024 / 1024)) & "MiB • "
  813.             end if
  814.         end if
  815.        
  816.        
  817.         --Front Side Bus
  818.         if ViewFSB is true then
  819.             set fsb to do shell script "sysctl -n hw.busfrequency"
  820.             set fsbtype to do shell script "cat /tmp/SPHardwareDataType.txt"
  821.             set temp to round (fsb / 1000000) rounding down
  822.             if cputype contains "AMD" then
  823.                 set msg to msg & FBold & "HT:" & FBold
  824.                 set msg to msg & " " & temp & "MHz • "
  825.             else if fsbtype contains "Interconnect" then
  826.                 set msg to msg & FBold & "QPI:" & FBold
  827.                 set msg to msg & " " & (temp / 1000) & " GT/s • "
  828.             else
  829.                 set msg to msg & FBold & "FSB:" & FBold
  830.                 set msg to msg & " " & temp & " MT/s • "
  831.             end if
  832.         end if
  833.        
  834.         --Ram
  835.         if ViewRam is true then
  836.             set memtotal to do shell script "sysctl hw.memsize"
  837.             set AppleScript's text item delimiters to ": "
  838.             set memtotal to text item 2 of memtotal
  839.             set memtotal to memtotal / 1024 / 1024 as integer
  840.             set topresult to do shell script "top -l 1 | head -n 7 | tail -n 1"
  841.             set AppleScript's text item delimiters to ", "
  842.             set memitems to text items of topresult
  843.             set AppleScript's text item delimiters to ""
  844.             set usedmem to text item 4 of memitems
  845.             set AppleScript's text item delimiters to "M"
  846.             set usedmem to text item 1 of usedmem
  847.            
  848.             set mempercent to (usedmem / memtotal) * 100 as integer
  849.             set mempercent to mempercent as text
  850.             set activebar to round (mempercent / 10) rounding to nearest
  851.             set activebar to activebar
  852.             if memtotal ≥ 1024 then
  853.                 set memtotal to (memtotal round) / 1024
  854.                 set memmeasure to "GiB"
  855.             else
  856.                 set memmeasure to "MiB"
  857.             end if
  858.             if usedmem ≥ 1024 then
  859.                 set usedmem to usedmem / 1024
  860.                 set usedmem to (round (usedmem * 100)) / 100
  861.                 set usedmeasure to "GiB"
  862.             else
  863.                 set usedmem to (round (usedmem * 100)) / 100
  864.                 set usedmeasure to "MiB"
  865.             end if
  866.             set memspeed to do shell script "system_profiler SPMemoryDataType | grep 'Speed:' | awk '{ print $2,$3 }'"
  867.             set AppleScript's text item delimiters to " MHz"
  868.             set memspeed to text item 1 of memspeed
  869.             if memspeed contains "Empty" then
  870.                 set AppleScript's text item delimiters to " "
  871.                 set memspeed to last text item of memspeed
  872.             end if
  873.             set msg to msg & FBold & "RAM: " & FBold & usedmem & usedmeasure & "/" & memtotal & memmeasure & " @ " & memspeed & "MHz"
  874.             --RAMBar
  875.             if ViewBars is true then
  876.                 set countervar to 0
  877.                 if activebar > 10 or activebar < 0 then
  878.                     return "Error!"
  879.                 else
  880.                     repeat until countervar = 10
  881.                         if activebar = 0 then
  882.                             set fullbar to FreeColor & "❙❙❙❙❙❙❙❙❙❙"
  883.                             set countervar to 10
  884.                         else if activebar = 10 then
  885.                             set fullbar to UsedColor & "❙❙❙❙❙❙❙❙❙❙"
  886.                             set countervar to 10
  887.                         else if activebar > 0 and activebar < 10 then
  888.                             set fullbar to UsedColor
  889.                             repeat activebar times
  890.                                 set fullbar to fullbar & "❙"
  891.                                 set activebar to (activebar - 1)
  892.                                 set countervar to (countervar + 1)
  893.                             end repeat
  894.                             set fullbar to fullbar & SeparatorColor & "|" & FreeColor
  895.                             repeat (10 - countervar) times
  896.                                 set fullbar to fullbar & "❙"
  897.                                 set countervar to (countervar + 1)
  898.                             end repeat
  899.                         end if
  900.                         exit repeat
  901.                     end repeat
  902.                 end if
  903.                 set msg to msg & " [" & fullbar & CWhite & "]"
  904.             end if
  905.             set msg to msg & " • "
  906.         end if
  907.        
  908.         --HDD
  909.         if ViewDisk is true then
  910.             set allFree to 0
  911.             set allSpace to 0
  912.             if ShowAllDisks is "True" then
  913.                 set myList to list disks
  914.                 repeat with i in myList
  915.                     set diskName to (i as string)
  916.                     try
  917.                         set freespace to round (the (free space of disk diskName) / 1024 / 1024)
  918.                         set totalspace to round (the (capacity of disk diskName) / 1024 / 1024)
  919.                         set allFree to allFree + freespace
  920.                         set allSpace to allSpace + totalspace
  921.                     end try
  922.                 end repeat
  923.                 set allUsed to allSpace - allFree
  924.             else
  925.                 set allUsed to do shell script "df -k | tail +2 | awk '{print $3}' | tail -r | tail -1"
  926.                 set allUsed to (allUsed / 1024)
  927.                 set allSpace to do shell script "df -k | tail +2 | awk '{print $2}' | tail -r | tail -1"
  928.                 set allSpace to (allSpace / 1024)
  929.             end if
  930.             set hdpercent to round ((allUsed / allSpace) * 100) rounding to nearest
  931.             set allUsed to allUsed / 1024
  932.             set allUsed to (round allUsed * 100) / 100
  933.             set allSpace to allSpace / 1024
  934.             set allSpace to (round allSpace * 100) / 100
  935.             if allUsed is greater than 1024 then
  936.                 set allUsed to allUsed / 1024
  937.                 set allUsed to (round allUsed * 100) / 100
  938.                 set usedunit to "TiB"
  939.             else
  940.                 set usedunit to "GiB"
  941.             end if
  942.             if allSpace is greater than 1024 then
  943.                 set allSpace to allSpace / 1024
  944.                 set allSpace to (round allSpace * 100) / 100
  945.                 set spaceunit to "TiB"
  946.             else
  947.                 set spaceunit to "GiB"
  948.             end if
  949.             if ViewBars is true then
  950.                 --Calculate and Draw bar size only if viewbars is true
  951.                 set hdbar to round (hdpercent / 10) rounding to nearest
  952.                 if hdbar = 0 then
  953.                     set hdfullbar to FreeColor & "❙❙❙❙❙❙❙❙❙❙" & CWhite
  954.                 else if hdbar = 1 then
  955.                     set hdfullbar to UsedColor & "❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙❙❙❙❙❙" & CWhite
  956.                 else if hdbar = 2 then
  957.                     set hdfullbar to UsedColor & "❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙❙❙❙❙" & CWhite
  958.                 else if hdbar = 3 then
  959.                     set hdfullbar to UsedColor & "❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙❙❙❙" & CWhite
  960.                 else if hdbar = 4 then
  961.                     set hdfullbar to UsedColor & "❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙❙❙" & CWhite
  962.                 else if hdbar = 5 then
  963.                     set hdfullbar to UsedColor & "❙❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙❙" & CWhite
  964.                 else if hdbar = 6 then
  965.                     set hdfullbar to UsedColor & "❙❙❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙❙" & CWhite
  966.                 else if hdbar = 7 then
  967.                     set hdfullbar to UsedColor & "❙❙❙❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙❙" & CWhite
  968.                 else if hdbar = 8 then
  969.                     set hdfullbar to UsedColor & "❙❙❙❙❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙❙" & CWhite
  970.                 else if hdbar = 9 then
  971.                     set hdfullbar to UsedColor & "❙❙❙❙❙❙❙❙❙" & SeparatorColor & "|" & FreeColor & "❙" & CWhite
  972.                 else if hdbar = 10 then
  973.                     set hdfullbar to UsedColor & "❙❙❙❙❙❙❙❙❙❙" & CWhite
  974.                 end if
  975.                 --HD Temperature
  976.                 if ViewTemp is true then
  977.                     if hdresult is "" then
  978.                         set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit & " [" & hdfullbar & "]"
  979.                     else
  980.                         set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit & " [" & hdfullbar & "] " & FBold & "Temp: " & FBold & hdresult & "ºC"
  981.                     end if
  982.                 else
  983.                     set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit & " [" & hdfullbar & "]"
  984.                 end if
  985.             else
  986.                 if ViewTemp is true then
  987.                     if hdresult is "" then
  988.                         set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit
  989.                     else
  990.                         set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit & FBold & " Temp: " & FBold & hdresult & "ºC"
  991.                     end if
  992.                 else
  993.                     set msg to msg & FBold & "HD: " & FBold & allUsed & usedunit & "/" & allSpace & spaceunit
  994.                 end if
  995.             end if
  996.             set msg to msg & " • "
  997.         end if
  998.        
  999.         --Display
  1000.         if ViewDisplay is true then
  1001.             if exists POSIX file "/tmp/SPDisplaysDataType.txt" then
  1002.             else
  1003.                 do shell script "system_profiler SPDisplaysDataType > /tmp/SPDisplaysDataType.txt"
  1004.             end if
  1005.             set gfxcard to do shell script "cat /tmp/SPDisplaysDataType.txt | head | grep -a 'Chipset Model:'"
  1006.             set AppleScript's text item delimiters to ":"
  1007.             set gfxcard to text item 2 of gfxcard
  1008.             set msg to msg & FBold & "GPU:" & FBold & gfxcard & " "
  1009.             --GFXBus
  1010.             if ViewGFXBus is true then
  1011.                 set bus to do shell script "cat /tmp/SPDisplaysDataType.txt | head | grep -a 'Bus:' | awk '{print $2}'"
  1012.                 set msg to msg & "[" & bus & "] "
  1013.             end if
  1014.             --VRAM
  1015.             set vram to do shell script "cat /tmp/SPDisplaysDataType.txt | head | grep -a 'VRAM (Total):' | awk '{print $3 $4}'"
  1016.             set msg to msg & "[" & vram & "] "
  1017.             --Resolutions
  1018.             if ViewResolutions is true then
  1019.                 set displaycheck to do shell script "cat /tmp/SPDisplaysDataType.txt | grep -a 'Resolution:' -c"
  1020.                 if displaycheck contains "0" then
  1021.                     set respretty to ""
  1022.                 else
  1023.                     if displaycheck contains "1" then
  1024.                         --set resolution to do shell script "system_profiler SPDisplaysDataType | grep -a 'Resolution:'"
  1025.                         set respretty to do shell script "cat /tmp/SPDisplaysDataType.txt | grep -a 'Resolution:' | awk '{print $2$3$4}' | head -n1"
  1026.                         set msg to msg & FBold & "Res: " & FBold & respretty
  1027.                     else
  1028.                         --set resolution to do shell script "system_profiler SPDisplaysDataType | grep -a 'Resolution:'"
  1029.                         set respretty to do shell script "cat /tmp/SPDisplaysDataType.txt | grep -a 'Resolution:' | awk '{print $2$3$4}' | head -n1"
  1030.                         set respretty2 to do shell script "cat /tmp/SPDisplaysDataType.txt | grep -a 'Resolution:' | awk '{print $2$3$4}' | tail -n 1"
  1031.                         set msg to msg & FBold & "Res: " & FBold & respretty & " & " & respretty2
  1032.                     end if
  1033.                 end if
  1034.             end if
  1035.             set msg to msg & " • "
  1036.         end if
  1037.        
  1038.         --Audio
  1039.         if ViewAudio is true then
  1040.             set kextstat to do shell script "kextstat"
  1041.             if kextstat contains "IOAudioFamily" then
  1042.                 if kextstat contains "AC97" then
  1043.                     set audio to "AC'97"
  1044.                 else if kextstat contains "AppleHDA" then
  1045.                     set audio to "Apple HDA"
  1046.                 else if kextstat contains "AppleAzaliaAudio" then
  1047.                     set audio to "Azalia"
  1048.                 else if kextstat contains "AppleUSBAudio" then
  1049.                     set audio to "SB Live! 24-Bit External"
  1050.                 else if kextstat contains "voodoohda" then
  1051.                     set audio to "VoodooHDA"
  1052.                 else
  1053.                     set audio to "Unknown"
  1054.                 end if
  1055.             else
  1056.                 set audio to "None"
  1057.             end if
  1058.             set msg to msg & FBold & "Audio: " & FBold & audio & " • "
  1059.         end if
  1060.        
  1061.         --Power
  1062.         if ViewPower is true then
  1063.             do shell script "pmset -g ps > /tmp/batstats"
  1064.             set pstats to do shell script "cat /tmp/batstats | tail -n1 | awk '{print $2,$3,$4}'"
  1065.             if pstats is "drawing from 'AC" then
  1066.                 set msg to msg
  1067.             else
  1068.                 set AppleScript's text item delimiters to ";"
  1069.                 set pcharge to text item 1 of pstats
  1070.                 set pstatus to text item 2 of pstats
  1071.                 set timeleft to text item 3 of pstats as string
  1072.                 if pstatus = " charging" then
  1073.                     if timeleft is " (no" then
  1074.                         set msg to msg & FBold & "Power: " & FBold & pcharge & " [charging]. • "
  1075.                     else
  1076.                         set msg to msg & FBold & "Power: " & FBold & pcharge & " [charging]," & timeleft & " left. • "
  1077.                     end if
  1078.                 else if pstatus = " discharging" then
  1079.                     if timeleft is " (no" then
  1080.                         set msg to msg & FBold & "Power: " & FBold & pcharge & " • "
  1081.                     else
  1082.                         set msg to msg & FBold & "Power: " & FBold & pcharge & "," & timeleft & " left. • "
  1083.                     end if
  1084.                 else if pstatus = " charged" then
  1085.                     set msg to msg & FBold & "Power: " & FBold & pcharge & " • "
  1086.                 end if
  1087.             end if
  1088.         end if
  1089.        
  1090.         --OS Version
  1091.         if ViewOSXVersion is true then
  1092.             set osxversion to do shell script "system_profiler SPSoftwareDataType | grep -a 'System Version:' | awk '{print $3,$4,$5,$6}'"
  1093.             set msg to msg & FBold & "OS: " & FBold & osxversion & " "
  1094.             if ViewOSXArch is true then
  1095.                 set FindKernelArch to do shell script "uname -a"
  1096.                 if FindKernelArch contains "x86_64" then
  1097.                     set KernelArch to "64-bit"
  1098.                 else if FindKernelArch contains "i386" then
  1099.                     set KernelArch to "32-bit"
  1100.                 else
  1101.                     set KernelArch to "Unknown"
  1102.                 end if
  1103.                
  1104.                 set msg to msg & KernelArch & " "
  1105.             end if
  1106.             if ViewOSXBuild is true then
  1107.                 set OSXBuild to do shell script "system_profiler SPSoftwareDataType | grep -a 'System Version:' | awk '{print $7}'"
  1108.                 set msg to msg & OSXBuild & " "
  1109.             end if
  1110.             set msg to msg & "• "
  1111.         end if
  1112.        
  1113.        
  1114.         --Kernel Version
  1115.         if ViewKernel is true then
  1116.             set temp to do shell script "uname -v"
  1117.             set AppleScript's text item delimiters to ";"
  1118.             set temp to text item 2 of temp
  1119.             set AppleScript's text item delimiters to ":"
  1120.             set kernbuilder to text item 1 of temp
  1121.             if kernbuilder contains "made by" then
  1122.                 set AppleScript's text item delimiters to "made by"
  1123.                 set kernbuilder to text item 2 of kernbuilder
  1124.             end if
  1125.             if kernbuilder contains "root" then
  1126.                 set kernbuilder to " Darwin"
  1127.             end if
  1128.            
  1129.             set kernver to do shell script "uname -r"
  1130.             set msg to msg & FBold & "Kernel:" & FBold & kernbuilder & " " & kernver
  1131.             if ViewKernelBuild = true then
  1132.                 set xnupre to do shell script "uname -v"
  1133.                 if xnupre contains "legacy" then
  1134.                     -- for hacks with legacy kernels
  1135.                     set xnubuild to do shell script "uname -v | awk '{print $11}' | cut -b 1-31"
  1136.                 else if xnupre contains "11.0" then
  1137.                     -- for OS X 10.7 Lion
  1138.                     set xnubuild to do shell script "uname -v | awk '{print $11}' | cut -b 6-21"
  1139.                 else
  1140.                     -- for OS X 10.6 Snow Leopard
  1141.                     set xnubuild to do shell script "uname -v | awk '{print $11}' | cut -b 6-20"
  1142.                 end if
  1143.                 set msg to msg & " " & "(" & xnubuild & ")"
  1144.             end if
  1145.             set msg to msg & " • "
  1146.         end if
  1147.        
  1148.        
  1149.         --Uptime
  1150.         if ViewUptime is true then
  1151.             set uptime to do shell script "uptime | awk '{sub(/.*up[ ]+/,\"\",$0) ; sub(/,[ ]+[0-9]+ user.*/,\"\",$0);sub(/,/,\"\",$0) ;print $0}'"
  1152.             repeat
  1153.                 if uptime contains "  " then
  1154.                     set AppleScript's text item delimiters to "  "
  1155.                     set temp1 to text item 1 of uptime
  1156.                     set temp2 to text items 2 thru end of uptime
  1157.                     set uptime to temp1 & " " & temp2
  1158.                 else
  1159.                     exit repeat
  1160.                 end if
  1161.             end repeat
  1162.             set msg to msg & FBold & "Uptime: " & FBold & uptime & " • "
  1163.         end if
  1164.        
  1165.        
  1166.         --Client
  1167.         if ViewClient is true then
  1168.             set linkver to version of application "Textual"
  1169.             if ViewTextualBuild is "True" then
  1170.                 set linkpath to POSIX path of (path to application "Textual")
  1171.                 set temp to do shell script "cat " & linkpath & "/Contents/Info.plist | grep Reference -A 1"
  1172.                 set AppleScript's text item delimiters to "<string>"
  1173.                 set temp to text item 2 of temp
  1174.                 set AppleScript's text item delimiters to "</string>"
  1175.                 set linkbuild to text item 1 of temp
  1176.                 set msg to msg & FBold & "Client: " & FBold & "Textual " & linkver & " [" & linkbuild & "] • "
  1177.             else
  1178.                 set msg to msg & FBold & "Client: " & FBold & "Textual " & linkver & " • "
  1179.             end if
  1180.         end if
  1181.        
  1182.        
  1183.         --Script Version
  1184.         if ViewScriptVersion is true then
  1185.             set msg to msg & FBold & "Script: " & FBold & "xsysinfo " & ScriptVersion & " • "
  1186.         end if
  1187.        
  1188.         --Remove last separator
  1189.         if HideFinalDot is "True" then
  1190.             repeat until msg does not end with " "
  1191.                 set msg to text 1 thru -2 of msg
  1192.             end repeat
  1193.             repeat until msg does not end with "•"
  1194.                 set msg to text 1 thru -2 of msg
  1195.             end repeat
  1196.         end if
  1197.        
  1198.        
  1199.     end tell
  1200.     return msg
  1201. end textualcmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement