Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd osx notifications through apple script - exercise_time - announce workout …
git clone git://src.adamsgaard.dk/exercise_time
Log
Files
Refs
LICENSE
---
commit bfb50faf6928ef38e7160c4e3ee0cdf4e0738517
parent 42e9b291df03ea4159e56aced53b3d8688c5cf15
Author: Anders Damsgaard <[email protected]>
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(-)
---
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 offi…
# 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 exerci…
+ 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
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.