1

Using system_profiler SPDisplaysDataType, I can retrieve the size of a Mac's display in pixels. However, the command

tell application "System Events" to get the size of every window of every process

(which I execute from my bash script using osascript) apparently does NOT return window sizes in pixels. It seems to be some other units. According to my experiments, on my MacBook Pro Retina, for instance, a fullscreen app (e.g., Keynote presentation) has a window size of 1680 x 1050.

So, the question is: how can I determine the screen size of a Mac from my bash script in the same units like the tell application ... uses? Or, how can I determine the factor by which I have to convert pixels into those other units?

1 Answer 1

1

You can get the screen size with this command

fullscreen_size=$( osascript -e 'tell application "Finder" to get bounds of window of desktop' )

in the same units as tell application "System Events" ....

2
  • I'm running High Sierra on my old iMac and the Applescript line "tell application "Finder" to get bounds of window of desktop" doesn't work. Was this command changed in Catalina? When I run this single line in the Script Editor I get an error message that says "Can’t get bounds of window of desktop."
    – Natsfan
    Commented Jul 10, 2020 at 22:19
  • Sorry, couldn't tell, since i never tried it on older versions of macOS and don't have access to an older macOS
    – Gab
    Commented Jul 12, 2020 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .