One-Click Do Not Disturb Mode Toggle with Alfred

This article introduces how to implement a one-click Do Not Disturb mode toggle with Alfred, including the advantages, implementation details, related resources, etc. These steps can help improve the efficiency of toggling Do Not Disturb mode.

Apr 23, 2021 · 1 min read · 158 Words · -Views -Comments · Software & Tools
Alfred Workflow 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

It’s been a while since I last updated an Alfred Workflow article, so here’s a recent small development.

During work, I often enable Mac’s Do Not Disturb mode to focus on coding and avoid bombardment from high-frequency messages like WeChat/QQ. However, I need to turn it off after work. Moving the mouse to the right side to turn it off is inefficient, and setting up hotkeys requires memorizing complex combinations. Neither of these approaches feels programmer-like, so I created a workflow for quick toggling.

Effect

Type ‘disturb’ and press Enter to toggle.

Workflow download link, click here

Implementation Details

After searching online, I found that neither AppleScript nor Shell offered reasonable solutions. Finally, I discovered this package @sindresorhus/do-not-disturb, which allowed implementation with just a few lines of code.

Looking through the source code, the underlying implementation is in Swift, with only JS-style calls exposed externally.

At the end

Now, I can toggle it nicely without leaving the keyboard.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover