He estado tratando de crear un script para deshabilitar/habilitar el Centro de notificaciones, incluso si es temporal. Debería hacer lo mismo que deslizar manualmente el Centro de notificaciones, desplazarse hacia arriba y alternar la insignia "Mostrar alertas y banner".
Alguien sabe si es posible y como hacerlo? :)
¡Gracias!
Para deshabilitar el Centro de notificaciones desde la línea de comando, escriba una clave KeepAlive que sea falsa en /System/Library/LaunchAgents/com.apple.notificationcenterui.plist así:
sudo defaults write /System/Library/LaunchAgents/com.apple.notificationcenterui KeepAlive -bool false
Si desea volver a habilitar el Centro de notificaciones, simplemente ejecute lo mismo con un verdadero:
sudo defaults write /System/Library/LaunchAgents/com.apple.notificationcenterui KeepAlive -bool true
Método para DESHABILITAR sin sudo:
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
killall NotificationCenter
Método para HABILITAR sin sudo:
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
Luego simplemente presione Comando + Shift + G y vaya a /System/Library/CoreServices/ luego busque "Centro de notificaciones" y haga doble clic para iniciarlo nuevamente
Simplemente hago clic con la tecla Alt en el ícono de la barra de menú, que en realidad lo atenúa y lo desactiva hasta que se vuelve a hacer clic en él.
Me encontré con esta pregunta 4 años después buscando lo mismo y se me ocurrió este AppleScript que alternará el estado habilitado del Centro de notificaciones:
(*
Toggle enabled state of Notification Center menu item
Notification Center can be enabled/disabled by clicking the menu item with the Option key pressed.
*)
tell application "System Events"
set ncMenu to menu bar 2 of application process "SystemUIServer"
set ncItem to menu bar item 1 of ncMenu
set ncTitle to title of ncItem
set ncTitleEnabled to "Notification Center"
set ncTitleDisabled to "Notification Center, Do Not Disturb enabled"
if (ncTitle = ncTitleEnabled or ncTitle = ncTitleDisabled) then
-- toggle enabled state of Notification Center
key down {option}
click menu bar item ncTitle of ncMenu
key up {option}
else
-- can't access Notification Center menu
display dialog "Notification Center is not available." with title "Applescript Error" buttons {"OK"} default button "OK"
end if
end tell
Guárdelo como nc.scpt y ejecútelo en la terminal creando un alias en su bash ~/.profile:
alias nc="osascript ~/path/to/nc.scpt"
Desde OS X Mavericks, es posible que reciba un error acerca de que osascript necesita permiso para las "características de accesibilidad". Deberá agregar Terminal a la lista de aplicaciones permitidas para controlar su computadora (Preferencias del sistema> Seguridad y privacidad> Privacidad> Accesibilidad). Dado que esto permite que cualquier secuencia de comandos de terminal acceda a la GUI, puede ser mejor convertir la secuencia de comandos en una aplicación de Automator y solo otorgar este privilegio a su aplicación.
Puede crear un atajo de teclado para la aplicación Automator. Consulte Cómo saltar rápidamente a otra aplicación sin usar la pestaña de comando . Por cierto, obtuve las entrañas del menú del Centro de notificaciones con el navegador de la interfaz de usuario (prueba gratuita).
Ramiro Araújo
MnO