Search code examples
macosluaapplescript

osx - script to get current desktop number


Is there a way to get current desktop/space number on osx programatically?

I've found this questions but it seems to be a little bit outdated: OSX Lion AppleScript : How to get current space # from mission control?

I've also found this: http://www.hammerspoon.org/docs/hs.spaces.watcher.html but unfortunately it does not work.


Solution

  • Since recent OS version, it is no longer possible to access via script to spaces. the only thing I found is how to get, via Applescript the name/path of desktop picture on current space :

    tell application "Finder" to set A to (desktop picture) as string
    

    Except that, since Yosemite (at least !) Applescript dictionary no longer contain space scriptable elements.