How to get (logical) screen size from a shell script?

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?


Solution 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" ....