commit bfb50faf6928ef38e7160c4e3ee0cdf4e0738517
parent 42e9b291df03ea4159e56aced53b3d8688c5cf15
Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Mon, 25 May 2015 11:24:48 +0200
add osx notifications through apple script
Diffstat:
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/exercise_time.sh b/exercise_time.sh
@@ -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
@@ -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
@@ -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
@@ -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