From e332c6f3af2fc58ea789611fe60feddfd1f44b46 Mon Sep 17 00:00:00 2001 From: michaeldimmitt Date: Mon, 5 Feb 2018 04:00:20 -0500 Subject: [PATCH] #19, internet checking solution looks as if it is working. --- .../Contents/Resources/script | 16 ++++++++++--- .hide/app/install/battery_check.sh | 23 +++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/.hide/app/install/DesktopBackgroundChanger.app/Contents/Resources/script b/.hide/app/install/DesktopBackgroundChanger.app/Contents/Resources/script index ba2afe4..6892e8e 100755 --- a/.hide/app/install/DesktopBackgroundChanger.app/Contents/Resources/script +++ b/.hide/app/install/DesktopBackgroundChanger.app/Contents/Resources/script @@ -12,7 +12,10 @@ test_date() { case $(echo $num_lines) in [0-1]) date +%s >> $DIR/.timestamp.txt - `/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`; + if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop; + then `/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`;# echo Internet status: OK; + else osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"'# echo Internet status: ERROR; + fi | tail -n 1 ;; [2]) old_time=`cat $DIR/.timestamp.txt`; @@ -25,11 +28,18 @@ test_date() { else sed -i '' '1d' $DIR/.timestamp.txt; date +%s >> $DIR/.timestamp.txt; - `/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`; + if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop; + then `/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`;# echo Internet status: OK; + else osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"'# echo Internet status: ERROR; + fi | tail -n 1 fi ;; *) say "should never happen let me reset!"; - rm $DIR/.timestamp.txt;`/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background` + rm $DIR/.timestamp.txt; + if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop; + then `/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`;# echo Internet status: OK; + else osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"'# echo Internet status: ERROR; + fi | tail -n 1 ;; esac } diff --git a/.hide/app/install/battery_check.sh b/.hide/app/install/battery_check.sh index 5179873..7e57af1 100755 --- a/.hide/app/install/battery_check.sh +++ b/.hide/app/install/battery_check.sh @@ -1,4 +1,10 @@ #!/bin/bash + +# gather information to be able to run scripts from this file location. +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# say $DIR +# end gather information. + # find out if charging result=$(ioreg -l | grep IsCharging | cut -d " " -f 19;) echo $result @@ -21,16 +27,16 @@ else fi # end check battery to acceptance criteria. -# gather information to be able to run scripts from this file location. -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# say $DIR -# end gather information. - # perform actions based on computer's charged state. if [ "$result" == "Yes" ] ; then # echo Charging; + if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop; + then $DIR/./3_install_launch_agent.sh# echo Internet status: OK; + else osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"'# echo Internet status: ERROR; + fi | tail -n 1 + # osascript -e 'display notification "Since Computer is Charging, program ok." with title "Aerial Desktop"' - $DIR/./3_install_launch_agent.sh + elif [ "$result" == "No" ] ; then echo Not Charging; if (( $(echo "$percentage < $battery_threshold" | bc -l) )) ; then @@ -40,7 +46,10 @@ elif [ "$result" == "No" ] ; then else # echo but at an acceptable battery level. # osascript -e 'display notification "Computer not charging and but at an acceptable battery level, program ok." with title "Aerial Desktop"' - $DIR/./3_install_launch_agent.sh + if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop; + then $DIR/./3_install_launch_agent.sh# echo Internet status: OK; + else osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"'# echo Internet status: ERROR; + fi | tail -n 1 fi else osascript -e 'display notification " something went wrong, contact michael; did some bad programming." with title "Aerial Desktop"'