Jump to content

Calm Notifications — Toggle Do Not Disturb Focus Mode


Recommended Posts

@vitor I still love this and use it many times per day. It's probably what I use Alfred for the most, so thank you!

 

One thing I stumble across is every now and again it hangs like in this video - it'll be stuck on "Getting status..." for a while, and I just have to wait until it finally shows the number before I hit return.

 

Have you experienced this? I wonder if there's something known I can tinker with, or if anything is interfering with it.

 

image.thumb.png.9705f921606dea4e434931b8a1ff92d6.png

 

 

Link to comment
15 minutes ago, alfredpanda said:

I still love this and use it many times per day. It's probably what I use Alfred for the most, so thank you!

 

Thank you for the kind words!

 

38 minutes ago, alfredpanda said:

Have you experienced this?

 

Never that long! For reference, the way I’m getting the status is by running the following command (you can try it in a terminal):

 

/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'

 

If it returns 0, Do Not Disturb is off; if 1, it’s on.

 

That command may be taking long to execute on your machine, for some reason. Or it may be the check Apple does on executables. Do note the Workflow has an External Triggers, so if you don’t really care about the feedback and just want to turn it on or off, you can take advantage of that.


I’ll eventually rewrite that part of the Workflow (so it no longer needs Ruby) and will check if macOS 13 has another way to check the status.

Link to comment

You can run the above command once in a while to see if it’s the one being slow. If it happens occasionally and those are after you haven’t used it in a while, I’d say it’s macOS checking the script. I have an idea which might work, but it’ll have to wait for the mentioned rewrite.

Link to comment

@vitor So I just noticed a delay, quickly backed out of Alfred, ran the script in Terminal which returned the number instantly, re-opened Alfred and CalmNotificaitons worked instantly. Hard to tell what causes the delay - but running the script in terminal almost fixed it - or made it work instantly?

Link to comment
8 hours ago, vitor said:

Running the command right after getting the delay won’t work, because what (presumably) causes the delay is run once then cached for a while. Try this version and see if you still get the delay. It should still happen the first time, but no more after that.

So far so good!! Thanks so much ❤️

 

EDIT: Is it normal to take a while after the computer has been to sleep?

Edited by alfredpanda
Link to comment

@Ghost. I need your exact versions of:

  • Alfred.
  • macOS.
  • CalmNotifications.

 

Did it work previously for you and stopped, or has it always been like this?

 

Also, turn Do Not Disturb on manually and run this in a Terminal:

 

/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'

 

What’s the output? Then turn Do Not Disturb off manually and repeat the command. What is the output?

Link to comment

Alfred: 4.6.6

MacOS: 12.4

CalmNotifications: 21.9

 

Yea, it worked before not sure what the heck happened tbh

 

I got this, when I manually turned it on:

/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'

1

 

I got this when I manually turned it off:

/usr/bin/defaults read com.apple.controlcenter 'NSStatusItem Visible FocusModes'
1

 

That being said, it seems the issue is on my end since the system detects focus mode as on even though it's not. At least that's what it seems like it after the command always returns 1.

Link to comment
2 hours ago, Ghost said:

That being said, it seems the issue is on my end since the system detects focus mode as on even though it's not. At least that's what it seems like it after the command always returns 1.

 

Yep, that is exactly right. Unclear why it’s happening, though. Do note the value sometimes takes a second or two to change. I’d think back if you installed something new recently which might be interfering. But before that I’d do a good old reboot, if you haven’t already.

Link to comment
On 6/11/2022 at 3:06 PM, vitor said:

Running the command right after getting the delay won’t work, because what (presumably) causes the delay is run once then cached for a while. Try this version and see if you still get the delay. It should still happen the first time, but no more after that.

FYI I'm sure this version runs a lot better. Seems like the first time I use it each day its slower, but then haven't had it again. Thank you!

Link to comment
  • 1 month later...
3 hours ago, jamesgc said:

Does anybody have this working on Monterey?

 

The Workflow only works on Monterey, it uses a macOS shortcut. For Big Sur and below, a different solution is needed, as per the top post.

 

3 hours ago, jamesgc said:

All mine ever says is "turn it off", even when Focus is off already.

 

Note that the file macOS changes when Do Not Disturb is toggled takes longer to change from on to off than the reverse. It may take a few seconds for the Workflow to be able to see the result.

 

I just pushed an update which rewrites the Workflow in JXA and auto-refreshes the state while Alfred’s window is open on dnd.

 

If it still doesn’t work for you, see the conversation above with @Ghost.

Link to comment

I tried the terminal command from your conversation with ghost, it consistently returns a 1 for me, even if i wait a minute. No matter what focus mode I set manually. 

Also tried rebooting my machine. 

Edited by jamesgc
Link to comment
10 hours ago, vitor said:

Figured out a better way to detect Do Not Disturb status. Seems to be both more reliable (does not depend on Menu Bar icon setting) and faster to return state.

 

Just released a new Workflow version with the change.

 

Nice!!!!! It works perfect now!!! :D Thank you. Will be using this a lot!

Link to comment
  • 2 months later...
  • vitor changed the title to Calm Notifications — Toggle Do Not Disturb Focus Mode

Updated to 2023.1.


Workflow is now distributed via the Alfred Gallery. Download the new version from there or update directly from Alfred.

  • New repository.
  • New icons.
  • New About.
  • Add configurable keyword.
  • Use shortcut even for checking status.
  • Show message to install shortcut inline.
  • Remove OneUpdater in favour of Gallery updating.

Due to recent macOS changes, you will need to update the installed shortcut. The workflow will prompt you to do so; overwrite the old one.

Link to comment
  • 2 weeks later...
On 3/25/2023 at 10:18 PM, vitor said:

Updated to 2023.3.


When defining a time-frame, preview the auto-stop hour.

 

Thanks for the on-going updates here - this is still probably my most-used workflow.

 

In the latest update I noticed the time, e.g "Enable until 11:42" - but the time for me is an hour behind. I am in the UK where we're on BST. Is there something I should change here?

 

Thanks!

 

image.thumb.png.29fb6dd510b450d3d4e2c600e7b0a266.png

Link to comment

@alfredpanda Nothing you need to change. Funnily enough, I remember coding that in the evening of the the DST change and was getting a seemingly wrong result which was in fact correct due to the hour change. Anyway, just released a new update to fix the display. Thank you for the catch.

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