3

I want to be able to switch between the tabs (Today and Notifications tabs) in Notification Center using a keyboard shortcut. Any way of doing it on macOS Sierra?

I know it was possible on Yosemite, but I never had Yosemite so I couldn't verify that.

Edit: I want to be able to run an apple script, not use a keyboard shortcut. Using the apple script I can then place it in a third-party program to get my results.

Also, the code below worked partially. For starters, is it possible to place an if/else at the beginning so it works like this:

if Notification Center is already opened, then move onto the next thing (which would be switching between the Today and Notification buttons) but if it is not open then open it and switch the buttons.

2
  • I'm not sure what makes you think there was a keyboard shortcut for it on Yosemite, but this question states otherwise. I don't think there has ever been one.
    – tubedogg
    Commented Sep 26, 2016 at 18:01
  • Assuming this question applies to any input method, is there a trackpad gesture that switches between the two tabs? I think most people stay with one view, recently my habits changed and I use info from both. In iOS, I drag the segment controls around to switch a lot now (this might not be new, but I started using it recently). This doesn't work in macOS notification (nor does the look of the controls suggest it should).
    – benc
    Commented Jul 3, 2020 at 4:34

2 Answers 2

0

I did a little googling and couldn't find a native keyboard shortcut other then to just open Notification Center, to whatever view it was last on, and this has to be User set in System Preferences > Keyboard > Shortcuts > Mission Control > Show Notification Center. This of course just open Notification Center to whatever view it was last on.

However if you go to System Preferences > Keyboard > Shortcuts, there is "Full Keyboard Access: In windows and dialogs, press Tab to move keyboard focus between:" and two radio buttons, "Text boxes and lists only" (the default) and "All controls". If you select "All controls", then you might be able to use, e.g. tab, enter, arrow keys to navigate the Notification Center. I'm not able to test that at the moment and why I said "... might be able to use ...".

That leaves an AppleScript workaround to be used in either a third-part app that can use the script assigning a keyboard shortcut or an Automator service that a keyboard shortcut could be assigned to.

The AppleScript code below toggles the state of the two buttons in Notification Center.

try
    tell application "System Events"
        tell process "SystemUIServer"
            click menu bar item "Notification Center" of menu bar 1
        end tell
        tell application "System Events"
            tell process "Notification Center"
                if value of radio button "Today" of radio group 1 of window "NotificationTableWindow" is equal to 1 then
                    click radio button "Notifications" of radio group 1 of window "NotificationTableWindow"
                else
                    click radio button "Today" of radio group 1 of window "NotificationTableWindow"
                end if
            end tell
        end tell
    end tell
end try

You can also modify the code to just act on just a given button if you want. It should be obvious how to modify it however fell free to ask if you need additional help.

2
  • Okay, I've played around with it a little bit and it actually worked. Partially. It will only work when Notification Center is closed. Also, Do Not Disturb cannot be enabled otherwise it will crash and give the following error: System Events got an error: Can’t get menu bar item "Notification Center" of menu bar 1 of process "SystemUIServer"
    – JRDNXr
    Commented Sep 27, 2016 at 22:37
  • 1
    @user3735534, you can wrap the example code above in a try statement, so it doesn't throw a critical error. I've aded it to the answer. Commented Sep 27, 2016 at 23:53
0

In macOS High Sierra, the Notification Center window accessibility name has changed to "Notification Center".

The following AppleScript should allow toggling between the two tabs (Today and Notifications) in macOS High Sierra (10.13), Sierra (10.12), and possibly earlier versions as well.

on osVersion()
    set _major to system attribute "sys1" -- 10
    set _minor to system attribute "sys2" -- 13 for High Sierra
    return (_major as string) & "." & (_minor as string)
end osVersion

on toggleNotificationCenter()
    tell application "System Events"
        tell process "SystemUIServer"
            click menu bar item "Notification Center" of menu bar 1
        end tell
    end tell
end toggleNotificationCenter

on toggleCenterButton()
    set notificationWindowName to "Notification Center" -- High Sierra
    considering numeric strings
        if osVersion() < "10.13" then
            set notificationWindowName to "NotificationTableWindow"
        end if
    end considering

    tell application "System Events"
        tell process "Notification Center"
            if value of radio button "Today" of radio group 1 of window notificationWindowName is equal to 1 then
                click radio button "Notifications" of radio group 1 of window notificationWindowName
            else
                click radio button "Today" of radio group 1 of window notificationWindowName
            end if
        end tell
    end tell
end toggleCenterButton


try
    toggleNotificationCenter()
    toggleCenterButton()
on error
    toggleNotificationCenter()
    toggleCenterButton()
end try

You must log in to answer this question.

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