tadd osx notifications through apple script - exercise_time - announce workout exercises with notifications and speech synth
 (HTM) git clone git://src.adamsgaard.dk/exercise_time
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit bfb50faf6928ef38e7160c4e3ee0cdf4e0738517
 (DIR) parent 42e9b291df03ea4159e56aced53b3d8688c5cf15
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Mon, 25 May 2015 11:24:48 +0200
       
       add osx notifications through apple script
       
       Diffstat:
         M exercise_time.sh                    |      18 ++++++++++++++----
       
       1 file changed, 14 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/exercise_time.sh b/exercise_time.sh
       t@@ -37,13 +37,20 @@ fi
        
        # announce exercise the specified number of times
        UNAMESTR=`uname`
       +
       +if [[ "$UNAMESTR" == 'Darwin' ]]; then
       +    IP=`/sbin/ifconfig | grep 10.17.8`
       +else
       +    IP=`ip addr | grep 10.17.8`
       +fi
       +
        for ((i=0; i<$1; i++)); do
        
            announcement="It's exercise time! $2"
        
            # Send message to notification daemon if computer is plugged in at my office
            # desk
       -    if [[ "$(ifconfig | grep 10.17.8)" ]]; then
       +    if [[ $IP ]]; then
                if command -v notify-send &>/dev/null; then
                    notify-send "$announcement"
                fi
       t@@ -54,7 +61,8 @@ for ((i=0; i<$1; i++)); do
            if [ $SPEECHSYNTH -eq 1 ]; then
                # OS X
                if [[ "$UNAMESTR" == 'Darwin' ]]; then
       -            if [[ "$(ifconfig | grep 10.17.8)" ]]; then
       +            osascript -e "display notification \"$2\" with title \"It's exercise time\""
       +            if [[ $IP ]]; then
                        say "$announcement"
                    fi
        
       t@@ -63,7 +71,7 @@ for ((i=0; i<$1; i++)); do
        
                    playingmusic=0
        
       -            if [[ "$(ip addr | grep 10.17.8)" ]]; then
       +            if [[ $IP ]]; then
                        if command -v mpc &>/dev/null; then
                            if [[ "$(mpc | grep playing)" ]]; then
                                mpc pause &> /dev/null
       t@@ -84,5 +92,7 @@ for ((i=0; i<$1; i++)); do
                fi
            fi
        
       -    sleep $WAITSECS
       +    if [[ $i -lt $(($1 - 1)) ]]; then
       +        sleep $WAITSECS
       +    fi
        done