Skip to content

Commit

Permalink
macos: dnd needs to be enabled "differently" for Big Sur
Browse files Browse the repository at this point in the history
I.e. there does not seem to be an officially supported way. I delegate
toggling DND (not idempotent!) to BetterTouchTool until I find a better
solution.

sindresorhus/do-not-disturb#9
  • Loading branch information
agross committed Nov 13, 2020
1 parent c7570cd commit 59760e1
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions macos/bin/dnd
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,19 @@

autoload -U colors && colors

defaults=(
defaults
-currentHost
write
~/Library/Preferences/ByHost/com.apple.notificationcenterui
)
toggle_dnd='tell application "BetterTouchTool"
trigger_action "{\"BTTPredefinedActionType\":200}"
end tell
'

function dnd::on() {
local enabledAt=$(date -u '+%Y-%m-%d %H:%M:%S +0000')

$defaults doNotDisturb -boolean true
$defaults doNotDisturbDate -date "$enabledAt"

killall NotificationCenter
osascript <<< $toggle_dnd > /dev/null

printf 'DND turned %bon%b\n' "$fg[green]" "$reset_color"
}

function dnd::off() {
$defaults doNotDisturb -boolean false
defaults -currentHost \
delete \
~/Library/Preferences/ByHost/com.apple.notificationcenterui \
doNotDisturbDate

killall NotificationCenter
osascript <<< $toggle_dnd > /dev/null

printf 'DND turned %boff%b\n' "$fg[red]" "$reset_color"
}
Expand Down

0 comments on commit 59760e1

Please sign in to comment.