OSX Lion AppleScript : How to get current space # from mission control?

前端 未结 7 1101
悲&欢浪女
悲&欢浪女 2020-12-07 11:09

I\'m trying to figure out how to get the current space # from mission control. Source would be helpful, but more helpful would be info on how to figure this out myself. I\

7条回答
  •  温柔的废话
    2020-12-07 11:53

    I'm on Mountain Lion and this seems to work for me.

    defaults read com.apple.spaces

    Look for "Current Space". You'll notice that running this command with different active spaces doesn't change the current space BUT if you check and uncheck a checkbox button in "System Preferences" and run it again, you'll see it updated.

    Hopefully this helps someone else!

    EDIT: It's ugly, but I'm using this:

    killall Dock && sleep 0.2 && defaults read com.apple.spaces | grep -A1 "Current Space" | tail -1 | awk '{print $NF }' | cut -f1 -d';'

提交回复
热议问题