How to invoke a specific Notification Center View using keyboard shortcuts on Mac

Notification Center View using keyboard shortcuts

Earlier this week, I showed you how to mate Notification Center to a keyboard shortcut. But wouldn’t it be cool if you could designate which View you’d like to see when invoking Notification Center from a keyboard shortcut? In this tutorial, I’ll show you how to open directly to the Today View or the Notifications View using keyboard shortcuts.

First, I did a little digging and stumbled upon this handy AppleScript from Skela on StackExchange:

tell application "System Events" to tell process "SystemUIServer"
 click menu bar item "Notification Center" of menu bar 2
end tell
 
tell application "System Events"
 tell process "Notification Center"
 click radio button "Notifications" of radio group 1 of window "NotificationTableWindow"
 end tell
end tell

The AppleScript above opens the Notification Center to the Notifications View, but what about Today View? All it takes is a simple alteration. Notice the difference?

tell application "System Events" to tell process "SystemUIServer"
 click menu bar item "Notification Center" of menu bar 2
end tell
 
tell application "System Events"
 tell process "Notification Center"
 click radio button "Today" of radio group 1 of window "NotificationTableWindow"
 end tell
end tell

On line 7 I changed Notifications to Today for the radio button value. Now, whenever this particular script is executed, it’ll open Notification Center up to the Today View.

While it’s great to have working scripts, we still need to mate these scripts to their respective keyboard shortcuts. In order to do this, I’ll use Automator. Since Automator allows one to create services, and services can be called on via keyboard shortcuts, this provides me with a great way to mate each script with a specific keyboard shortcut.

Step 1: Launch Automator

Step 2: Click File → New → Service, and click the Choose button

Automator Service

Step 3: In the search box type AppleScript and double-click on the AppleScript action

Step 4: Click the Services receives selected drop-down box, and choose no input

Step 5: Now, simply paste the first script posted above in the Run AppleScript box where it says (* Your script goes here *)

Step 6: Click File → Save, and give your service a name. I call mine Notifications View

Step 7: Repeat steps 1-6, but use the Today View script for Step 5, and the Today View name for Step 6

Note: Services are saved to the ~/Library/Services folder, so you can always go there to manage them if you need to.

Assigning a keyboard shortcut to the services

After creating the two services, you can close Automator. It’s now time to mate those services to a keyboard shortcut of your choice.

The only catch is that the shortcut must include use of the Command (⌘) key, or else it won’t work properly inside apps without manually invoking the service from the menu bar. This is apparently due to a bug in the way OS X handles shortcuts to services that don’t include the ⌘ key. I tore my hair out about this for a few hours, before I finally stumbled on this thread on the Apple support forums.

Another thing to keep in mind is that you should avoid using the Option (⌥) key in your shortcut. I explain why down below.

Step 1: Open System Preferences → Keyboard

Step 2: Click the Shortcuts tab and click Services

Step 3: Scroll to the bottom of the list, and under the General disclosure triangle, you should see your two newly created services: Notifications View and Today View

Step 4: Click Notifications View, ensure the check mark box is checked, and click add shortcut

Step 5: Press a keyboard shortcut combination on your keyboard to submit the shortcut. Be sure to include ⌘ in your shortcut, and avoid the ⌥ key.

Step 6: Repeat step 4 and 5 for the Today View service

Important: Avoid using the Option (⌥) key in your keyboard shortcut combination, because the option key will interfere with Notification Center. Option-clicking is associated with invoking Do Not Disturb mode, which will cause you problems and may cause the shortcut not to work.

What do you think?