prezto/modules/notify/functions/should_auto_notify
Alex Reece 36559d9978 Add changes from sorin codereview
-    autoload functions aren't surrounded in an addition function { }
-    export cross platform notify function
-    control notify behavior with zstyles
2013-06-13 16:22:53 -04:00

35 lines
723 B
Text

# Check if it makes sense to load the notify module.
#
# Checks for requirements, that it is an xsession, etc.
#
# Authors:
# Alex Reece <awreece@gmail.com>
#
if ! zstyle -t ':prezto:module:notify' auto-notify; then
return 1
fi
case "$OSTYPE" in
(darwin*)
# TODO(awreece) Disable if ssh with no windows?
is-callable terminal-notifier || is-callable growlnotify
;;
(linux-gnu*)
# Disable if don't have X.
if [[ -z $XAUTHORITY ]]; then
return 1
fi
# We need both of these functions to operate.
if (( ! $+commands[notify-send] || ! $+commands[xprop] )); then
return 1
fi
return 0
;;
(*)
# If we don't know, then just disable.
return 1
;;
esac