태그 보관물: do-not-disturb

do-not-disturb

매버릭스의 쉘에서 방해 사절을 활성화 / 비활성화하는 방법은 무엇입니까? 키보드 단축키에

알림 센터에서 방해 금지를 키보드 단축키로 전환하고 싶습니다.

일부 추가 키보드 단축키에 BetterTouchTool을 사용하고 있지만 기본 옵션에서 알림 활성화 / 비활성화를 지원하지 않습니다.

여기에는 터미널 명령을 실행하는 옵션이 있으므로 여기에서 터미널에서 방해 사절을 활성화 / 비활성화하는 방법을 묻습니다.

OS X Mountain Lion With Automator에서 ‘방해 금지’일정을 찾았 는데 명령을 실행하려고했지만 작동하지 않는 것 같습니다.



답변

시스템 환경 설정-> 키보드-> 단축키-> 미션 컨트롤에서 글로벌 키보드 단축키를 설정할 수 있습니다.

또는 명령 행에서 확실히 원한다면, 애플 스크립트가이를 수행합니다 (키보드 단축키를 사용하도록 설정 한 경우) cmdshiftoptctrlD.

이것이 작동하려면 여전히 시스템 환경 설정에서 키보드 명령을 설정해야합니다.

아래 스크립트를 ~ / dnd.applescript 파일에 넣으십시오.

ignoring application responses
    tell application "System Events" to keystroke "D" using {command down, shift down, option down, control down}
end ignoring

이제 osascript ~/dnd.applescript명령 줄에서 실행 하여 DND 설정을 전환 할 수 있습니다.

스크린 캡 :


답변

OS X 10.10.3부터이 AppleScript는 “방해 사절”을 토글합니다. 키보드 단축키가 필요하지 않습니다.

tell application "System Events" to tell process "SystemUIServer"
  key down option
  click menu bar item 1 of menu bar 2
  key up option
end tell

AppleScript로 저장하고로 터미널에서 실행 osascript DoNotDisturb.applescript하거나 heredoc에 다음과 같이 배치하여 Bash 스크립트에 포함시킬 수 있습니다.

#!/bin/bash
osascript <<EOD
  tell application "System Events" to tell process "SystemUIServer"
    key down option
    click menu bar item 1 of menu bar 2
    key up option
  end tell
EOD

답변

defaults 명령에 대한 인수를 사용하여 razvanz가 제공하는 답변을 단순화 할 수 있습니다 -currentHost.

방해 사절 활성화 :

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +0000\"`"
killall NotificationCenter

( https://heyfocus.com/blog/enabling-do-not-disturb-mode/ 를 통해 )

방해 사절 비활성화 :

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean false
killall NotificationCenter

이제 시스템 환경 설정에 관계없이 다른 사람의 컴퓨터에서 작동하는 스크립트로 “방해 금지”를 활성화 또는 비활성화하기 위해이를 스크립트로 쉽게 정리할 수 있습니다. 이를 수행하는 방법의 예는 다음과 같습니다.

#!/bin/bash

set -eou pipefail

# From https://heyfocus.com/enabling-do-not-disturb-mode and
# /apple/145487

if [[ $(defaults -currentHost read ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb) -eq 0 ]]; then
  defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean true
  defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturbDate -date "`date -u +\"%Y-%m-%d %H:%M:%S +000\"`"
  killall NotificationCenter
  echo "Do Not Disturb is enabled. Run $0 to turn it off (OS X will turn it off automatically tomorrow)."
else
  defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui doNotDisturb -boolean false
  killall NotificationCenter
  echo "Do Not Disturb is disabled. Run $0 to turn it on again."
fi

출처 : https://gist.github.com/ryangreenberg/5267f68a8e7b07ea66370b4eb5580ab9


답변

James와 Zsolt의 답변을 바탕으로 DND 상태를 설정하거나 해제 (토글하지 않음)하는 몇 가지 스크립트를 만들었습니다. 또한 키 바인딩이나 시스템 GUID가 필요하지 않습니다.

중요 :이 스크립트를 처음 실행하려면 스크립트를 실행하는 앱에 대한 접근성 권한이 필요할 수 있습니다. 요청에 권한을 부여하지 않으면 시스템에 대해 alt/ option버튼을 누른 상태로 유지하고 “누르지 않기”위해 로그 아웃했다가 다시 로그인해야합니다. AppleScript를 사용한 이전 답변에서도 마찬가지입니다. 스크립트가 편집되면 권한을 취소하고 다시 부여해야합니다. 다음을 사용하여 권한이 부여됩니다.

System Preferences > Security & Privacy > Accessibility > Add your app

macOS Sierra 및 High Sierra의 경우 menu bar 1다음과 같습니다.

방해 사절 켜기 (알림 비활성화) :

if [[ $(plutil -convert xml1 -o - ~/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist | grep false) ]]; then
    osascript <<EOD
      tell application "System Events" to tell process "SystemUIServer"
        key down option
        click menu bar item 1 of menu bar 1
        key up option
      end tell
EOD
fi

방해 금지 해제 (알림 사용) :

if ! [[ $(plutil -convert xml1 -o - ~/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist | grep false) ]]; then
    osascript <<EOD
      tell application "System Events" to tell process "SystemUIServer"
        key down option
        click menu bar item 1 of menu bar 1
        key up option
      end tell
EOD
fi

이전 버전의 macOS의 경우 menu bar 2다음과 같습니다.

방해 사절 켜기 (알림 비활성화) :

if [[ $(plutil -convert xml1 -o - ~/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist | grep false) ]]; then
    osascript <<EOD
      tell application "System Events" to tell process "SystemUIServer"
        key down option
        click menu bar item 1 of menu bar 2
        key up option
      end tell
EOD
fi

방해 금지 해제 (알림 사용) :

if ! [[ $(plutil -convert xml1 -o - ~/Library/Preferences/ByHost/com.apple.notificationcenterui.*.plist | grep false) ]]; then
    osascript <<EOD
      tell application "System Events" to tell process "SystemUIServer"
        key down option
        click menu bar item 1 of menu bar 2
        key up option
      end tell
EOD
fi

답변

일정 이 방해받지 않음

명령 줄에서 방해 사절을 설정하여 매일 정해진 시간에 활성화 / 비활성화하도록 예약 할 수도 있습니다.

DND가 될 시간을 설정하려면 활성화 :

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui dndStart -integer <start_time_in_minutes>

DND가 될 때 시간을 설정하려면 사용할 수 :

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui dndEnd -integer <end_time_in_minutes>

참고 : 교체<start_time_in_minutes>하고<end_time_in_minutes>원하는 값 (아래 설명).


예:

DND가 매일 15:00에 시작하고 18:30에 끝나도록 예약하려면 다음을 수행하십시오.

분 변환 15:00 18:30의 가치를 얻을 수 <start_time_in_minutes><end_time_in_minutes>. 즉, 시간 수에 60을 곱하고 분 수를 더하십시오.

15:00 그 것 : 15 * 60 + 0 = 90018:30 동안 그는 다음과 같습니다 18 * 60 + 30 = 1110. 아래 명령을 우리에게주세요 :

defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui dndStart -integer 900
defaults -currentHost write ~/Library/Preferences/ByHost/com.apple.notificationcenterui dndEnd -integer 1110
killall NotificationCenter # 'resets' Notificatio Center so that it reads the DND change

답변

제임스의 대답을 바탕으로, 나는 그것이 켜져 있는지 여부를 결정할 수 있음을 지적하고 싶습니다. 따라서 다음은 전원을 끄고 이미 꺼져 있으면 아무 것도 수행하지 않습니다.

if [[ $(plutil -convert xml1 -o - ~/Library/Preferences/ByHost/com.apple.notificationcenterui.000-000-000-000.plist | grep false) ]]; then
    osascript <<EOD
      tell application "System Events" to tell process "SystemUIServer"
        key down option
        click menu bar item 1 of menu bar 2
        key up option
      end tell
EOD
fi

자신의 컴퓨터 GUID를 파일 이름으로 대체해야합니다 (파일이 하나만 있으므로 알아 내기 쉽습니다).


답변