1308515d1c2014a52aca3ac952a0172d9961eee0

Author
Kristján Oddsson <koddsson@gmail.com>
Committer
Kristján Oddsson <koddsson@gmail.com>
Date

Message

Re-order OS detection if..else statement.

This patch will re-order the if statements when checking what operating
system the user is running.

This is useful for people that already have a `notify-send` binary in
their $PATH but are running OSX. An example of such requirements is
anyone running `vagrant-notify` is required to have a `notify-send`
binary on their $PATH.

See [link](https://github.com/fgrehm/vagrant-notify#os-x).

Diff

 1diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
 2index 5ccead3b8fa6ab7fa5dfa18b6784cd4613b0dc52..14ca4c81726ede87c295765e10aeb19f6376d086 100755
 3--- a/plugins/bgnotify/bgnotify.plugin.zsh
 4+++ b/plugins/bgnotify/bgnotify.plugin.zsh
 5@@ -1,6 +1,5 @@
 6 #!/usr/bin/env zsh
 7 
 8-
 9 ## setup ##
10 
11 [[ -o interactive ]] || return #interactive only!
12@@ -21,22 +20,22 @@ if ! (type bgnotify_formatted | grep -q 'function'); then
13 fi
14 
15 currentWindowId () {
16-  if hash notify-send 2>/dev/null; then #ubuntu!
17-    xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }'
18-  elif hash osascript 2>/dev/null; then #osx
19+  if hash osascript 2>/dev/null; then #osx
20     osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
21+  elif hash notify-send 2>/dev/null; then #ubuntu!
22+    xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }'
23   else
24     echo $EPOCHSECONDS #fallback for windows
25   fi
26 }
27 
28 bgnotify () {
29-  if hash notify-send 2>/dev/null; then #ubuntu!
30-    notify-send $1 $2
31-  elif hash terminal-notifier 2>/dev/null; then #osx
32+  if hash terminal-notifier 2>/dev/null; then #osx
33     terminal-notifier -message "$2" -title "$1"
34   elif hash growlnotify 2>/dev/null; then #osx growl
35     growlnotify -m $1 $2
36+  elif hash notify-send 2>/dev/null; then #ubuntu!
37+    notify-send $1 $2
38   elif hash notifu 2>/dev/null; then #cygwyn support!
39     notifu /m "$2" /p "$1"
40   fi