Jump to content

Toggle Do Not Disturb


Recommended Posts

Posted

Useful, thank you!

Would be even better if it could indicate the current state of the "Do no disturb" toggle (either in the Alfred menu or in a notification)

  • 4 months later...
Posted (edited)

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
  • 4 months later...
Posted

I had the same problem.  I got it to work using the "Run Script" action (and selecting /usr/bin/osascript as the language) rather than using "Run NSApplescript".

 
  • 1 year later...
Posted

Hi all, I downloaded Ender's updated workflow last year - thank you so much! However, it doesn't seem to work when I have my computer set in another language. Is there any way to fix this?

 

Thanks,

Liat

  • 1 year later...
Posted (edited)

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
  • 11 months later...
Posted
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?

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...