xilopaint / alfred-about-this-mac

Shows About This Mac info in Alfred.
MIT License
25 stars 1 forks source link

Update for M1 #3

Closed ITRecords38 closed 2 years ago

ITRecords38 commented 3 years ago

Hi

Is an update possible?

Thanks

amm
xilopaint commented 3 years ago

Hi! I can't reproduce your issue on my side. The machine.png icon is retrieved by the getMacIcon.applescript created by @ChristoferK. I got in touch with him and he will help us in the coming days to debug the issue.

ITRecords38 commented 3 years ago

Hi! I can't reproduce your issue on my side. The machine.png icon is retrieved by the getMacIcon.applescript created by @ChristoferK. I got in touch with him and he will help us in the coming days to debug the issue.

Hi,

Really nice. Thank you. I'm waiting for your return 😉

ChristoferK commented 3 years ago

@GrimlocK38, sorry for keeping you waiting. To provide more clues as to where the problem might lie, and—just as importantly—where it does not, would you mind running the script below from within Script Editor ? It's a modified, stripped-down version of the script used by the Alfred workflow, containing only the essential lines necessary for generating the image appropriate for the machine.

Upon execution, the script should return either true or false. If it returns true, then you can run it again after removing the following line:

return the result

Removing that line will allow whatever image is generated by this script to open in Preview for you to discern whether or not it's what one would expect (i.e. not simply a blank image).


use framework "Foundation"
use framework "AppKit"

property this : a reference to the current application
property NSWorkspace : a reference to NSWorkspace of this
property sharedWorkspace : a reference to NSWorkspace's sharedWorkspace

property filepath : "/tmp/machine.tiff" as «class furl»

set root to the sharedWorkspace()'s iconForFileType:"'root'"
set tiff to root's TIFFRepresentation()
tell tiff to writeToURL:filepath atomically:yes

return the result

tell application id "com.apple.finder" to open filepath ¬
    using application file id "com.apple.Preview"
ITRecords38 commented 3 years ago

Hi @ChristoferK

I waited wisely but no problem :)

I just tested and got the right result

screen

I removed the line and got the picture. Am I replacing everything in the script now ?

  1. These 2 pieces of information are reversed

    screen
  2. you will update the info in the script for operation

Thanks

xilopaint commented 3 years ago
  1. These 2 pieces of information are reversed

I take care of this part. Please, post the Terminal output for system_profiler SPHardwareDataType.

ITRecords38 commented 3 years ago

Ok @xilopaint. Here

Last login: Fri Feb 19 06:48:14 on ttys000
itrecords@MacBook-Pro-M1 ~ % system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro17,1
      Chip: Apple M1
      Total Number of Cores: 8 (4 performance and 4 efficiency)
      Memory: 16 GB
      System Firmware Version: 6723.100.337.121.1
      OS Loader Version: 6723.100.337.121.1
      Serial Number (system): FVFDQ1ZGQ05P
      Hardware UUID: 00A09928-1610-502F-A415-78C10C428972
      Provisioning UDID: 00008103-001C644420C0291E
      Activation Lock Status: Enabled

itrecords@MacBook-Pro-M1 ~ % 
xilopaint commented 3 years ago

Could you test this build and post here the Alfred UI output image?

It should fix the processor part. I need the Terminal output for system_profiler SPDisplaysDataType to debug the graphics part.

ITRecords38 commented 3 years ago

@xilopaint,

I test. Thanks and here the processor part.

Last login: Fri Feb 19 08:27:22 on ttys000
itrecords@MacBook-Pro-M1 ~ % system_profiler SPDisplaysDataType
Graphics/Displays:

    Apple M1:

      Chipset Model: Apple M1
      Type: GPU
      Bus: Built-In
      sppci_cores: 8
      Vendor: Apple (0x106b)
      Metal Family: Supported, Metal GPUFamily Apple 7
      Displays:
        Color LCD:
          Resolution: 3360 x 2100
          UI Looks like: 1680 x 1050 @ 60.00Hz
          Main Display: Yes
          Mirror: Off
          Online: Yes
          Automatically Adjust Brightness: No
          Connection Type: Internal

itrecords@MacBook-Pro-M1 ~ %

Result

For image of processor possible logo Apple or not ?

screen
xilopaint commented 3 years ago

For image of processor possible logo Apple or not ?

I'm looking for an icon for Apple M1. Btw, Apple M1 is the right title for the graphics. What is this icon for the graphics, by the way? Did you put it by yourself? And why the resolution differs from your first image?

ITRecords38 commented 3 years ago
  1. For icon m1. Ok

  2. for the resolution I did not touch anything. I restarted the script by the editor. it can come from that

  3. By cons "About this Mac“ graphic lost

    aboutthismac
xilopaint commented 3 years ago

3. By cons "About this Mac“ graphic lost

I don't get what you tell here.

ITRecords38 commented 3 years ago

Sorry @xilopaint

I don't know if it's the script that at modify this part.

xilopaint commented 3 years ago

Sorry @xilopaint

I don't know if it's the script that at modify this part.

I'm struggling to understand you. Please, use Google Translate, it should do a good job with French. The icon your image shows for the graphic chipset doesn't come from the workflow I distribute. Where did you get it?

ITRecords38 commented 3 years ago

for icon graphic chipset. i changed here

icon
xilopaint commented 3 years ago

for icon graphic chipset. i changed here

I'm not asking where you changed but where you got the icon from.

ITRecords38 commented 3 years ago

@xilopaint, here : https://macosicons.com

ChristoferK commented 3 years ago

I waited wisely but no problem :)

I just tested and got the right result

screen

I removed the line and got the picture. Am I replacing everything in the script now ?

Not just yet. That was checking the core functionality of the script was doing what it was meant to, which means the problem with the original script must be in the conversion of the TIFF data to PNG data. The script achieved this previously using Image Events, which is the part of the process that is most likely to fail from upgrading to Big Sur (although it's strange that it appears to work as before for @xilopaint).

To be safe, I'll rewrite the script to perform the conversion without using Image Events.

On a minor note, the Objective-C method used to create the icon, namely iconForFileType:, is now deprecated as of Big Sur. There's a new method called iconForContentType:, which I will test when I install Big Sur. Since deprecated methods tend to remain functional for at least one major OS version, this isn't crucial right now.

I'll post an updated script this week. Thanks for your patience.

ITRecords38 commented 3 years ago

Hi @ChristoferK,

Thanks for your return. No problem, I wait wisely. Thanks to you 2 for the follow-up and the update :)

xilopaint commented 3 years ago

@ChristoferK any news on this?

ITRecords38 commented 3 years ago

@xilopaint @ChristoferK

Hi, I wait wisely. hoping that chris will be able to give us this update. Thanks again

ChristoferK commented 3 years ago

@xilopaint @GrimlocK38 Hello, thanks for nudging me. I've been distracted by multiple projects, plus my day job.

[ I'm a medical doctor and the entire year has been swallowed by CoViD, my time hasn't felt like my own. ]

I did write the replacement handler for converting a TIFF to and saving as a PNG. I have, erm, 164 script documents open in CotEditor, so it's in one of these. I've just written a JXA routine to search the open documents and bring the windows to the front, so I'll post some code this weekend.

Unrelated query: On contemplating installing Big Sur this weekend also, from the perspective of the impact the new OS has had on scripting, and any software† that either of you might use, has the upgrade been painful at all, and is there anything useful to be aware of in advance ?

†Alfred, Keyboard Maestro, Typinator, FastScripts, iTerm, FiSH shell, JXA, AppleScript, Hammerspoon, EventScripts, plus any scriptable applications that notably do less well since upgrading.


Bonjour, merci de m’avoir ecrivent. J’ai été distrait par plusieurs projets, et mon travail de jour (Je suis médecin et toute l’année a été avalée par CoViD, mon temps n’a pas senti comme le mien). J’ai écrit le subroutine de remplacement pour convertir un TIFF et économiser comme un PNG. J’ai, erm, 164 documents de script ouverts dans _CotEditor_, donc c’est dans l’un d’eux. Je viens d’écrire une routine JXA pour rechercher les documents ouverts et apporter les fenêtres à l’avant, donc je vais poster du code ce week-end.
**Requête sans rapport:** Sur la contemplation de l’installation de Big Sur ce week-end aussi, du point de vue de l’impact du nouveau système d’exploitation a eu sur le scripting, et tout logiciel**†** que l’un de vous pourrait utiliser, a la mise à niveau a été douloureux à tous, et y at-il quelque chose d’utile d’être conscient à l’avance? **†** _Alfred, Keyboard Maestro, Typinator, FastScripts, iTerm, FiSH shell, JXA, AppleScript, Hammerspoon, EventScripts_, ainsi que toutes les applications scriptables qui font notamment moins bien depuis la mise à niveau.
xilopaint commented 3 years ago

@ChristoferK Thank you for your service, Doc!

ChristoferK commented 3 years ago

Here we go, guys. This is the chunk of code that will safely generate the machine icon, saving it as a PNG image file, and returning the path to the file:

use scripting additions
use framework "AppKit"

property this : a reference to the current application
property nil : a reference to missing value
property NSBitmapImageRep : a reference to NSBitmapImageRep of this
property NSWorkspace : a reference to NSWorkspace of this

property filepath : POSIX file "/tmp/machine.png"

tell (TIFFRepresentation of iconForFileType_("'root'") ¬
    in the sharedWorkspace of NSWorkspace) to tell ¬
    representationUsingType_properties_(4, nil) of ¬
    (NSBitmapImageRep's imageRepWithData:it) to if ¬
    writeToURL_atomically_(filepath, yes) then ¬
    return the filepath's POSIX path

Do you want me to upload this as an .applescript file attachment ?

xilopaint commented 3 years ago

Do you want me to upload this as an .applescript file attachment ?

Yes, please. After we test it you can submit a PR if everything is ok.

xilopaint commented 2 years ago

Do you want me to upload this as an .applescript file attachment ?

@ChristoferK could you upload the file so we can test the new implementation?

xilopaint commented 2 years ago

@ChristoferK 👋

xilopaint commented 2 years ago

Apple Silicon support has been added.