Jump to content

Toggle Do Not Disturb


Recommended Posts

  • 4 months later...

This is broken in the Yosemite public beta (probably do to some menu bar reorganisation?) Anyway, I tinkered a bit but couldn't fix it. The best I came up with was this Applescript: 

tell application "System Events"
	tell process "SystemUIServer"
		try
			key down option
			click menu bar item 1 of menu bar 2
			key up option
		on error
			key up option
		end try
	end tell
end tell

Note the use of the try block. In the current version of the workflow the option key gets stuck pressed down, preventing you from typing normal characters until you restart System Events (or reboot your Mac).

 

I can see the script above clicking the Notification Centre icon, because the icon flashes blue when I run it. It doesn't actually toggle Do Not Disturb though.

Edited by Subject22
Link to comment
  • 4 months later...
  • 1 year later...
  • 1 year later...

None of the previous solutions worked for me so I tried to craft something myself and it worked! Running it successfully on El Capitan 10.11.6 with Bartender 2.

I got the code from this StackOverflow answer and converted into a simple Alfred workflow.

 

Should also work on any Mac (with or without Bartender) as long as Apple doesn't change the Notification Center plist location (I think...).

 

https://drive.google.com/file/d/0Bx3NCikqzbt5Qm1TdmkwQWFxUkU/view?usp=sharing

Edited by Jkscx
Beter formating
Link to comment
  • 11 months later...
On 10/26/2017 at 9:01 AM, Jkscx said:

None of the previous solutions worked for me so I tried to craft something myself and it worked! Running it successfully on El Capitan 10.11.6 with Bartender 2.

I got the code from this StackOverflow answer and converted into a simple Alfred workflow.

 

Should also work on any Mac (with or without Bartender) as long as Apple doesn't change the Notification Center plist location (I think...).

 

https://drive.google.com/file/d/0Bx3NCikqzbt5Qm1TdmkwQWFxUkU/view?usp=sharing

1

 

Hi, I tried this workflow and couldn't get it to work on MacOS Mojave. Any ideas?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...