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
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"
-
1This would technically work, but there's a catch. Changing the keyboard shortcut would break the automator app. Commented Oct 16, 2013 at 5:40
-
1You 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
-
1I 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. 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
-
1It'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
This method also works on Mac OS Ventura M2 Macbook. I combine it with skhd to trigger command via keyboard shortcut
-
can you clarify which method you're referencing? I'm unable to get the osascript commands to work for me via skhd– npp1993Commented Jan 10 at 5:01
-
1This 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"'
Commented Feb 28 at 19:25 -
1It 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