Find out which display_id is active for use with Ruby API

Is there a way to get the display_id of the active display? I am trying to write a script that shows me the name of the currently active space in the active display.

Thanks!

I’m sorry I don’t know a good way of getting that information from a ruby script.

You could call out to a Python script such as this:

from AppKit import NSScreen
print NSScreen.mainScreen().deviceDescription()[“NSScreenNumber”]

But on my machine this is not working how it’s supposed to. NSScreen.mainScreen() is supposed to return the screen containing the window with active focus, but I’m always getting the primary screen when I run this script.

Maybe it will work for you though.

Ok, thanks, I’ll try looking into that. Maybe I’ll just try to write a Obj-C program that spits out the screen number :wink: