5

The title pretty much says it all. I need to know the terminal commands for "Application Windows" and "Show Desktop" in Mountain Lion so I can make aliases on the dock with Automator. I don't like hot corners, mostly because there are only four corners on the screen and more OS functionality than that. Keyboard shortcuts are all well and good, I just want options.

2 Answers 2

7

You can execute "Mission Control" with specific arguments to trigger the behavior that you desire:

Mission Control:

/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control

Show Desktop:

/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 1

Application Windows:

/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 2

Alternately, you could use osascript to execute the key code that you have setup for "Application Windows" and "Show Desktop". In the example below, I have "Desktop" mapped to the F8 key, and "Application Windows" setup to use F9. The key codes for these F keys can be found in various places.

osascript -e "tell applications \"System Events\"" -e "key code 100" -e "end tell"

osascript -e "tell applications \"System Events\"" -e "key code 101" -e "end tell"
9
  • 1
    This would technically work, but there's a catch. Changing the keyboard shortcut would break the automator app.
    – user59565
    Commented Oct 16, 2013 at 5:40
  • 1
    You can use whichever keyboard shortcut you've got setup...You just need to substitute the codes that are provided in the example above with those of your own. The link in the answer above provides additional codes. Alternately - which keyboard shortcut are you using? Commented Oct 16, 2013 at 6:20
  • 1
    I mean that if I decide I want a different keyboard shortcut AFTER creating the automator app, I have to modify the workflow AS WELL. Considering my predilection for tinkering for the sake of tinkering, which means that I change keyboard shortcuts multiple times every week, this is actually a problem. I'm sorry, but this is not really a workable answer.
    – user59565
    Commented Oct 16, 2013 at 21:37
  • I've updated the answer with something that you may find to be more workable. Commented Oct 16, 2013 at 21:54
  • 1
    It's probably also worth mentioning that the Mission Control.app bundle has been relocated to /System/Applications/Mission Control.app in macOS Catalina (10.15) and later. Commented Jan 19, 2022 at 4:44
1

This method also works on Mac OS Ventura M2 Macbook. I combine it with skhd to trigger command via keyboard shortcut

3
  • can you clarify which method you're referencing? I'm unable to get the osascript commands to work for me via skhd
    – npp1993
    Commented Jan 10 at 5:01
  • 1
    This is the command that I use in my skhdrc file @npp1993; cmd + shift - d : osascript -e 'do shell script "/System/Applications/Mission\\ Control.app/Contents/MacOS/Mission\\ Control 1"'
    – alp tuğan
    Commented Feb 28 at 19:25
  • It seems the /System/Applications/Mission\ Control.app/Contents/MacOS/Mission\ Control 1 terminal command stopped working in Sonoma though. Commented Mar 30 at 20:09

You must log in to answer this question.

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