Skip to content

Instantly share code, notes, and snippets.

@ericdke
Last active February 8, 2018 20:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericdke/f666341fb2d54471a58d to your computer and use it in GitHub Desktop.
Save ericdke/f666341fb2d54471a58d to your computer and use it in GitHub Desktop.
Swift: get the Mac's "Do not disturb" state
if let uuid = getSystemUUID() {
let filepath = ("~/Library/Preferences/ByHost/com.apple.notificationcenterui.\(uuid).plist" as NSString).stringByExpandingTildeInPath
if let dict = NSDictionary(contentsOfFile: filepath), doNotDisturbState = dict["doNotDisturb"] as? Bool {
print(doNotDisturbState)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment