Jump to content

Request: About this Mac


Recommended Posts

Posted

Hey,

 

I'd like to be able to type "about" and have the About this Mac data appear within Alfred - hit return to copy to clipboard.

Also just "serial" or "model" would be handy.

 

Other additions/suggestions welcome as always.

 

Peace

Posted

Hey, Ive had some mild success with this:

 

This will print your Model Identifier ("      Model Identifier: MacBookAir5,1") to your clipboard so you can paste it somewhere:

/usr/sbin/system_profiler SPHardwareDataType | grep 'Model Identifier' | pbcopy

 

I would suggest using a workflow with a keyword of model

then running a /bin/bash script with that command in it

then outputting that all to a notification that just says your Model Identifier has been copied to your clipboard.

 

With regards to serial:

I've had some success with:

ioreg -l | grep IOPlatformSerialNumber | pbcopy

 

but it copies it like this:

    |   "IOPlatformSerialNumber" = "C02*********"

and I don't know how to reduce what it copies just down to the serial part (same goes for model identifier actually).

 

No idea how to make alfred show all this in its window.

 

Best of luck!

Posted

I'll get the ball rolling on this one: PLEASE keep in mind I know VERY little about scripting and even less about 'working with text' using awk and such ... with that in mind, here is a start:

 

Everything you need to obtain from "About This Mac" can be found with 3 terminal commands:

 

sw_vers
system_profiler SPHardwareDataType
system_profiler SPMemoryDataType

Now, I'm thinking that if you make a new workflow in Alfred2, add a script filter, set your keyword and select with space and argument optional, set the language to "/bin/bash" and in the script area paste the following:

 

sw_vers > atm.txt
system_profiler SPHardwareDataType >> atm.txt
system_profiler SPMemoryDataType >> atm.txt

This will create a txt file in the workflow folder named "atm.txt" with all of the info you need.

 

Parsing the data would be done using awk, and don't forget to add the xml outputs for whatever you want to display.

I am currently unaware of how to exactly output to clipboard when selecting and hitting enter on any of the output fields.

Oh, also, if you want the results to be listed in a certain 'non-learning' order, be sure to give unique identifiers to the the item fields.

 

Seriously, I've almost got this working myself with ZERO knowledge ... give it a go ... it's fun to learn!

Posted (edited)

OK, I could not leave this one alone because it was eating away at me. I am posting what I have so far here, and not in the workflow forum, because this is NOT 100% in my eyes, but it is certainly functional.

 

This workflow is outdated and the final can be found here

 

The keyword is currently "about" and you will see:

 

[image removed]

 

Upon completing the keyword you will see:

 

[image removed]

 

I have two clipboard outputs assigned to the script filter so that:

 

1: Selecting the result and hitting enter with "fn" will copy to the clipboard.

2: Selecting the result and hitting enter with "shift" will paste the value to the front most window.

 

Currently, the workflow results show:

 

1: Uptime

2: System Serial Number

3: System Version with build

4: Processor

5: Ram

 

NOW, the RAM is the issue for me ... STILL haven't found a way to parse the data from 'SPMemoryDataType' so I am currently using "SPHardwareDataType" and adding the ram speed/type manually.

 

NOTE: inside the workflow folder I have included icons for "Leopard" "Lion", the workflow is currently assigning the OS icon to "MountainLion" as that is what I am using.  Also, I have 2 CPU icons, i5 and i7, i5 is used, again, because this is my system.  Also, the back of the iMac icon is used for serial, yup, you guessed it, because that's my system. ALL icons are from Apple, either from their site or from the OS.

 

Ultimately, it would be nice to have the script parse the data and use whatever icon for whatever CPU/Mac/OS is in the file ... but as stated earlier, I know VERY little of bin/bash ... so hopefully someone else can contribute to this.

Edited by RodgerWW
Posted (edited)

For RAM could use:

sysctl hw.memsize

 

That retuns in in bits I believe. Then divide by 3072 (1024 * 3) and you get in GB the amount of RAM the user has

Edited by R4z3r
Posted (edited)

@ R4z3r : Ya, I found that too, BUT, I actually wanted to show the type and timing as well. There have been times when I just can't remember the exact specs.

 

OK, I found out how to parse the multiple values for RAM!

 

I also added the graphics card to the 'flow' because that may prove useful to some. {workflow NOT updated here yet, as I am in the middle of a bunch of stuff for it, AND, 'feels' close to finished so I MAY just release in the proper forum when done.}

 

Currently I am cleaning up the icons so that they appear as clean as they possibly can.

 

OK, I finally found out how Apple does the Human Readable Format for the machine from the model serial ... "iMac (27-inch, Mid 2011)"! NOW, I need to figure out how to parse out the data needed to send the curl request.

Edited by RodgerWW
Posted (edited)

OK folks here is Verison02

 

This version is outdated and the final can be found HERE.

 

Upon starting to type the KEYWORD "about" you will see:

 

[image removed]

When completing the keyword "about":

 

[image removed]

 

When selecting an item, then holding "fn" + "ENTER" it will copy the TITLE value to the clipboard.

When selecting an item, then holding "shift" + "ENTER" it will paste the title value to the front most app.

 

For Example: If I mouse down to "System Version (Build)" and hit "fn" + "ENTER" it will COPY "OS X 10.8.3 (12D78)" to my clipboard.

 

The workflow now includes 2 more modifiers!

Holding "ctrl" + "ENTER" anywhere, will open the Apple Support Site for YOUR hardware in your default browser.

Holding "opt" + "ENTER" anywhere, will open the Apple Technical Specifications Site for YOUR hardware in your default browser.

 

These two new added functions simulate the support links in "About This Mac", selecting "More Info", selecting the "Support" tab, then selecting either "Specifications" or "Hardware Support."

 

I personally thought this was a wicked idea to minimize the  amount of mouse movements and clicking necessary just to see if my hardware is still under warranty and what my support options are.  I've come a LONG way since using Alfred1 to simply launch apps ... this is all done with ZERO scripting knowledge folks! 

 

NOTES:

 

I still need to figure out the hardware icon that is displayed beside the human readable hardware. For NOW, I have it showing the "iMac (27-inch, Mid 2011)" icon Apple uses for MY hardware. This is not dynamic yet, as I need to figure out a reliable way to grab the icons Apple uses from "CoreTypes.bundle."

 

For now, you 'advanced' users can simply grab the appropriate icon for your hardware from "CoreTypes.bundle," copy it over to the workflow folder, then edit the <icon> attribute in the xml output to reflect the proper icon.

 

OK, so here's what I need from you fine folks reading this:

 

1: Please, try out the hotkeys, specifically the "ctrl" and the "alt" modifiers. I need to know that the method used to grab the data is current, and accurate. Apple has changed this over the years, and I am hoping they are sticking with the method I'm using for ALL hardware.

 

2: Alfred2 and/or scripting (/bin/bash/) GURUs ... please look over the scripting in the workflow and  help me clean it up if it needs to be. So far, everything 'works' for me, but as stated earlier, I've done all of this with zero knowledge and I would hate to have a sloppy workflow here.

Edited by RodgerWW
Posted

OK folks here is Verison02

 

Download V02

 

Upon starting to type the KEYWORD "about" you will see:

 

atmV021.png?w=AAB0zSAub2TERwRBFdCVWFIdPN

When completing the keyword "about":

 

atmV022.png?w=AABxdsFh6rU4QfsIPseAAQ_Vbc

 

When selecting an item, then holding "fn" + "ENTER" it will copy the TITLE value to the clipboard.

When selecting an item, then holding "shift" + "ENTER" it will paste the title value to the front most app.

 

For Example: If I mouse down to "System Version (Build)" and hit "fn" + "ENTER" it will COPY "OS X 10.8.3 (12D78)" to my clipboard.

 

The workflow now includes 2 more modifiers!

Holding "ctrl" + "ENTER" anywhere, will open the Apple Support Site for YOUR hardware in your default browser.

Holding "opt" + "ENTER" anywhere, will open the Apple Technical Specifications Site for YOUR hardware in your default browser.

 

These two new added functions simulate the support links in "About This Mac", selecting "More Info", selecting the "Support" tab, then selecting either "Specifications" or "Hardware Support."

 

I personally thought this was a wicked idea to minimize the  amount of mouse movements and clicking necessary just to see if my hardware is still under warranty and what my support options are.  I've come a LONG way since using Alfred1 to simply launch apps ... this is all done with ZERO scripting knowledge folks! 

 

NOTES:

 

I still need to figure out the hardware icon that is displayed beside the human readable hardware. For NOW, I have it showing the "iMac (27-inch, Mid 2011)" icon Apple uses for MY hardware. This is not dynamic yet, as I need to figure out a reliable way to grab the icons Apple uses from "CoreTypes.bundle."

 

For now, you 'advanced' users can simply grab the appropriate icon for your hardware from "CoreTypes.bundle," copy it over to the workflow folder, then edit the <icon> attribute in the xml output to reflect the proper icon.

 

OK, so here's what I need from you fine folks reading this:

 

1: Please, try out the hotkeys, specifically the "ctrl" and the "alt" modifiers. I need to know that the method used to grab the data is current, and accurate. Apple has changed this over the years, and I am hoping they are sticking with the method I'm using for ALL hardware.

 

2: Alfred2 and/or scripting (/bin/bash/) GURUs ... please look over the scripting in the workflow and  help me clean it up if it needs to be. So far, everything 'works' for me, but as stated earlier, I've done all of this with zero knowledge and I would hate to have a sloppy workflow here.

 

I can't get V2 to work. V1 is running fine.

Posted

Multiple chipsets look like this:

 

 

Graphics/Displays:
 
    Intel HD Graphics 4000:
 
      Chipset Model: Intel HD Graphics 4000
      Type: GPU
      Bus: Built-In
      VRAM (Total): 512 MB
      Vendor: Intel (0x8086)
      Device ID: 0x0166
      Revision ID: 0x0009
      gMux Version: 3.2.19 [3.2.8]
 
    NVIDIA GeForce GT 650M:
 
      Chipset Model: NVIDIA GeForce GT 650M
      Type: GPU
      Bus: PCIe
      PCIe Lane Width: x8
      VRAM (Total): 1024 MB
      Vendor: NVIDIA (0x10de)
      Device ID: 0x0fd5
      Revision ID: 0x00a2
      ROM Revision: 3688
      gMux Version: 3.2.19 [3.2.8]
      Displays:
        Color LCD:
          Display Type: LCD
          Resolution: 2880 X 1800
          Retina: Yes
          Pixel Depth: 32-Bit Color (ARGB8888)
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Built-In: Yes
          Connection Type: DisplayPort
Posted (edited)

@ Ddyracer : Do you happen to have v1 & v2 installed at the same time using the same keyword? I'm not exactly sure how that would be possible because the bundleID is the same. I need a little more info I think. What exactly happens when you start typing the keyword?

 

@ ctwise: Is that the output from written "atm.txt"? I think I may be able to fix this if I can figure out how to parse the multiple values with the same names. ALSO, I have to admit I am unfamiliar with the broad range of all the Macs out there, but is this perhaps one of those that has the multi-cards? If so, I can actually test out how to change this with my Son's Macbook Pro when he gets the time.

Edited by RodgerWW
Posted

OK folks here is Verison02

 

Download V02

 

Nice workflow. Just had one problem: I had to modify the workflow to use the last 3 digits of my serial number in the URL to get the machine name. Otherwise, the curl request just returned this, and caused no results to show:

 

<?xml version="1.0" encoding="utf-8" ?><root><error>0009</error><locale>en_US</locale></root>
Posted (edited)

@ Ddyracer : Do you happen to have v1 & v2 installed at the same time using the same keyword? I'm not exactly sure how that would be possible because the bundleID is the same. I need a little more info I think. What exactly happens when you start typing the keyword?

 

Nope.

 

 

Screen%20Shot%202013-04-03%20at%204.12.0

Edited by Ddyracer
Posted (edited)

Nice workflow. Just had one problem: I had to modify the workflow to use the last 3 digits of my serial number in the URL to get the machine name. Otherwise, the curl request just returned this, and caused no results to show:

 

<?xml version="1.0" encoding="utf-8" ?><root><error>0009</error><locale>en_US</locale></root>

 

Crap, I was afraid they still used 3 sometimes. I currently have no idea how to compensate for this automatically. If anyone has any ideas, please step forward!

 

Just had a brain fart. SO, what IF I I do a curl request with 3 characters, parse, and if the xml contains <error> skip, then goto a curl request with 4 characters? I THINK Apple has only ever used either 3 or 4. Hmmm, more learning to do, especially on how to do all that.

 

Upon testing my own mac serial with just 3 characters, all I get is the wrong model identifier, NOT an error in the xml ... damn. So far the only way I know of how Apple gets that link is the method I'm currently using. And yet, it works on ALL macs when we do it from the system menu ... so, perhaps the exact method Apple uses in the OS is not documented correctly online. This is going to bug me!

Edited by RodgerWW
Posted

Nope.

 

 

Screen%20Shot%202013-04-03%20at%204.12.0

 

OK, this LOOKS like it might be hanging up on a script. ONE thing that comes to mind is the curl request for the machine code that Clinton mentioned as well.

 

type the following in terminal but NOTE the {DIGITSHERE}:

 

curl -o - "http://support-sp.apple.com/sp/product?cc={DIGITSHERE}〈=en_US"
 

REPLACE {DIGITSHERE}, including the {} with the last 4 characters of your serial as shown in about this mac (system menu one) 

if you get an error as shown in Clinton's post, then it's required to put the last 3 instead. Otherwise, it will just show your proper machine code in xml

 

that is the MAJOR change in v2 ... so let me know if that was it, just so we can eliminate that

Posted

OK, this LOOKS like it might be hanging up on a script. ONE thing that comes to mind is the curl request for the machine code that Clinton mentioned as well.

 

type the following in terminal but NOTE the {DIGITSHERE}:

 

curl -o - "http://support-sp.apple.com/sp/product?cc={DIGITSHERE}〈=en_US"
 

REPLACE {DIGITSHERE}, including the {} with the last 4 characters of your serial as shown in about this mac (system menu one) 

if you get an error as shown in Clinton's post, then it's required to put the last 3 instead. Otherwise, it will just show your proper machine code in xml

 

that is the MAJOR change in v2 ... so let me know if that was it, just so we can eliminate that

 

Ok, got the command to work using the last three digits.

Posted (edited)

Ok, got the command to work using the last three digits.

 

OK, I don't know if you have already done this, but I'll post this for others so they know what to do with this particular issue:

 

1: Open Alfred2's preferences

2: Select the workflow "About This Mac"

3: Double click on the script filter "about" to open the script it runs

4: find the line 

 

LAST4SERIAL=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print substr( $0, length($0) - 3, length($0) ) }')
 

5: modify the awk command to change the length from 4 characters to 3 or just replace that line with the following 

 

LAST4SERIAL=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print substr( $0, length($0) - 2, length($0) ) }')
 

6: You will also need to change those lines in the /bin/bash run scripts for the "ctrl" and "alt" modifiers ... for those scripts to actually work with 3 digit spec. (thanks derico for pointing this out!)

Edited by RodgerWW
Posted

OK, I don't know if you have already done this, but I'll post this for others so they know what to do with this particular issue:

 

1: Open Alfred2's preferences

2: Select the workflow "About This Mac"

3: Double click on the script filter "about" to open the script it runs

4: find the line 

 

LAST4SERIAL=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print substr( $0, length($0) - 3, length($0) ) }')
 

5: modify the awk command to change the length from 4 characters to 3 or just replace that line with the following 

 

LAST4SERIAL=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print substr( $0, length($0) - 2, length($0) ) }')
 

 

It works now, replaced the awk command with your second line. Thank you so much for your time.

Posted (edited)

[...]

 

These two new added functions simulate the support links in "About This Mac", selecting "More Info", selecting the "Support" tab, then selecting either "Specifications" or "Hardware Support."
 

I personally thought this was a wicked idea to minimize the  amount of mouse movements and clicking necessary just to see if my hardware is still under warranty and what my support options are.  I've come a LONG way since using Alfred1 to simply launch apps ... this is all done with ZERO scripting knowledge folks! 

 

[...]

 

OK, so here's what I need from you fine folks reading this:

 

1: Please, try out the hotkeys, specifically the "ctrl" and the "alt" modifiers. I need to know that the method used to grab the data is current, and accurate. Apple has changed this over the years, and I am hoping they are sticking with the method I'm using for ALL hardware.

 

2: Alfred2 and/or scripting (/bin/bash/) GURUs ... please look over the scripting in the workflow and  help me clean it up if it needs to be. So far, everything 'works' for me, but as stated earlier, I've done all of this with zero knowledge and I would hate to have a sloppy workflow here.

 

Hey Rodger,

 

this is a great workflow! I had to modify it to use the last 3 digits of my serial number, but that's an easy fix with your instructions above.

After doing this in the script filter as well as both bash scripts, even the links to specification site and hardware support work. I have to agree, this is a clever shortcut!

 

As I don't know much about scripting or alike I can't help you with that. But I think it works nicely.

Thanks for your effort,

Ricco

Edited by derico
Posted

I posted to the Apple forums, requesting a foolproof way of getting the link to the support/specification site for each model ... no responses yet. I'm starting to think perhaps I may have to remove the links (that functionality) in the final workflow, as it's not entirely universal, and requires too much work to get it to work for those that are new to alfred2: I am a FIRM believer in having things "JUST WORK."

Posted

Hey Rodger,

 

this is a great workflow! I had to modify it to use the last 3 digits of my serial number, but that's an easy fix with your instructions above.

After doing this in the script filter as well as both bash scripts, even the links to specification site and hardware support work. I have to agree, this is a clever shortcut!

 

As I don't know much about scripting or alike I can't help you with that. But I think it works nicely.

Thanks for your effort,

Ricco

Thanks for reminding me about the actual scripts...LOL. I updated the previous post to state that they indeed needed to be modified as well!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...