Skip to content

Commit

Permalink
Hey look, it scales! 🤓 and is lighter than ever! 🤔
Browse files Browse the repository at this point in the history
High Sierra still does not work.

next is menubar...
then fix the high sierra bug.
  • Loading branch information
MichaelDimmitt authored Feb 15, 2018
2 parents e40d305 + 7b312ef commit 317b8a8
Show file tree
Hide file tree
Showing 47 changed files with 203 additions and 1,355 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.tmp
.timestamp.txt
Binary file removed .hide/app/images/install.png
Binary file not shown.
Binary file removed .hide/app/images/uninstall.png
Binary file not shown.
15 changes: 15 additions & 0 deletions .hide/app/install/1_check_resource.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# !/bin/bash
screensaver=$1
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# run aerial application
if [ -d ~/Library/Screen\ Savers/$screensaver ]
then
open ~/Library/Screen\ Savers/$screensaver
elif [ -d /Library/Screen\ Savers/$screensaver ]
then
open /Library/Screen\ Savers/$screensaver
else
svn checkout https://github.com/MichaelDimmitt/sc/trunk/$screensaver;
open $screensaver
fi
10 changes: 0 additions & 10 deletions .hide/app/install/1_download_aerial.sh

This file was deleted.

57 changes: 57 additions & 0 deletions .hide/app/install/4_desktop_background_changer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/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.

# test_date() uninstall launch_agent if computer has slept twice quickly...
# handling potential high sierra catestrophy
check_launch_agent () {
if [ "$(launchctl list | grep aerial)" -ge 1 ];
then
osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"';
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh
else
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh;
fi
}

test_date() {
num_lines=$(cat $DIR/.timestamp.txt | wc -l)
case $(echo $num_lines) in
[0-1])
date +%s >> $DIR/.timestamp.txt
if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop;
then
sleep 3;
`/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`;# echo Internet status: OK;
else
check_launch_agent
fi | tail -n 1
;;
2)
old_time=`cat $DIR/.timestamp.txt`;
count=`expr $(date +%s) - $(sed -n '2p' $DIR/.timestamp.txt)`;
if [ "$count" -le 100 ]; then
osascript -e 'display notification "Uninstalled because you put your computer to sleep twice really quickly.😍✌️" with title "Uninstalled due rapid sleep, please reinstall."'
./$DIR/../uninstall/2_unstage_launch_agent.sh
else
sed -i '' '1d' $DIR/.timestamp.txt;
date +%s >> $DIR/.timestamp.txt;
if curl --silent --head https://github.com/michaeldimmitt/aerial_desktop;
then
sleep 3;
`/System/Library/Frameworks/ScreenSaver.framework/Resources/./ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background`;
# echo Internet status: OK;
else
check_launch_agent
# echo Internet status: ERROR;
fi | tail -n 1
fi
;;
*)
say "should never be reached"
esac
}
test_date;
39 changes: 0 additions & 39 deletions .hide/app/install/DesktopBackgroundChanger.app/Contents/Info.plist

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# !/bin/bash
screen=$1
saver='.saver'

# write out path needed
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo $DIR

#create .tmp file
mkdir $DIR/.tmp
cp $DIR/com.aerial.desktop.plist $DIR/.tmp/com.aerial.desktop.plist
cp $DIR/com.desktop.$screen.plist $DIR/.tmp/com.desktop.$screen.plist
cp $DIR/com.monitor.charge.plist $DIR/.tmp/com.monitor.charge.plist

# create the string needed.
pwd2=" <string>$DIR/./DesktopBackgroundChanger.app/Contents/Resources/script</string>"
pwd2=" <string>$DIR/./../4_desktop_background_changer.sh</string>"
pwd3=" <string>$DIR/./battery_check.sh</string>"
echo $pwd2
# insert path needed into correct file.
# line 9 in com.aerial.desktop.plist
sed -i '' '9s?.*?'"$pwd2"'?' $DIR/.tmp/com.aerial.desktop.plist
# line 9 in com.$screen.desktop.plist
sed -i '' '9s?.*?'"$pwd2"'?' $DIR/.tmp/com.desktop.$screen.plist
sed -i '' '9s?.*?'"$pwd3"'?' $DIR/.tmp/com.monitor.charge.plist

# change environment appropriately
chmod 644 $DIR/.tmp/com.aerial.desktop.plist
chmod 644 $DIR/.tmp/com.desktop.$screen.plist
chmod 645 $DIR/.tmp/com.monitor.charge.plist

cp $DIR/.tmp/com.aerial.desktop.plist ~/Library/LaunchAgents/
cp $DIR/.tmp/com.desktop.$screen.plist ~/Library/LaunchAgents/
cp $DIR/.tmp/com.monitor.charge.plist ~/Library/LaunchAgents/

launchctl load ~/Library/LaunchAgents/com.aerial.desktop.plist
launchctl load ~/Library/LaunchAgents/com.desktop.$screen.plist
launchctl load ~/Library/LaunchAgents/com.monitor.charge.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ get_percentage(){ numerator=$(ioreg -n AppleSmartBattery | grep CurrentCapacity
percentage="$(get_percentage)";
battery_threshold=.20;

battery_actions () {
if [ "$(launchctl list | grep -c aerial)" -ge 1 ];
then
osascript -e 'display notification "Computer not charging and low battery \nprogram disabled." with title "Aerial Desktop"';
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh;
else
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh;
fi
}

check_wifi () {
if [ "$(launchctl list | grep -c aerial)" -ge 1 ];
then
osascript -e 'display notification "Please connect your computer to internet." with title "Aerial Desktop"';
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh
else
$DIR/./../../uninstall/1_unstage_dyna_desktop.sh;
fi
}

if (( $(echo "$percentage > $battery_threshold" | bc -l) )) ; then
echo "$percentage greater than $battery_threshold"
elif (( $(echo "$percentage < $battery_threshold" | bc -l) )) ; then
Expand All @@ -31,34 +51,41 @@ fi
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;
then
sleep 3;
$DIR/./3_install_launch_agent.sh dyna;
else
check_wifi
fi | tail -n 1

# osascript -e 'display notification "Since Computer is Charging, program ok." with title "Aerial Desktop"'

elif [ "$result" == "No" ] ; then
echo Not Charging;
if (( $(echo "$percentage < $battery_threshold" | bc -l) )) ; then
# echo not charging and battery unacceptable level.
# osascript -e 'display notification "Computer not charging and low battery program disabled." with title "Aerial Desktop"'
$DIR/./../uninstall/unstage_aerial_desktop.sh
battery_actions
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"'
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;
then
sleep 3;
$DIR/./3_install_launch_agent.sh dyna;
else
check_wifi
fi | tail -n 1
fi
else
if [ "$(ioreg -n AppleSmartBattery | grep -c Max)" -ge 1 ];
then osascript -e 'display notification " something went wrong, contact michael; did some bad programming." with title "Aerial Desktop"'
else osascript -e 'display notification " Desktop Computer not needing battery consideration." with title "Aerial Desktop activating program."';
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;-
then
sleep 3;
$DIR/./3_install_launch_agent.sh dyna;
else
check_wifi
fi | tail -n 1
fi

fi
sleep 10
File renamed without changes.
18 changes: 18 additions & 0 deletions .hide/app/install/launch_agent/com.desktop.dyna.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.aerial.desktop</string>
<key>ProgramArguments</key>
<array>
<string>This is a test. Check if the file has been exists or has been modified in /.tmp/com.example.plist. If not, navigate to repo and run ./install_launch_agent.
</array>
<key>RunAtLoad</key>
<true/>
<key>SuccessfulExit</key>
<false/>
<key>StartInterval</key>
<integer>1</integer>
</dict>
</plist>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# !/bin/bash
if [ -d ~/Library/Screen\ Savers/Aerial.saver ] ; then
screensaver=$1
if [ -d ~/Library/Screen\ Savers/$screensaver ] ; then
defaults -currentHost write com.JohnCoates.Aerial shouldShowNameLabel 1
defaults -currentHost write com.apple.screensaver modulePath -string "/System/Library/Screen Savers/Shell.saver"; defaults -currentHost write com.apple.screensaver moduleName -string "Shell"; defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Shell path /System/Library/Screen\ Savers/Shell.saver/ type 0;
defaults -currentHost write com.apple.screensaver modulePath -string "~/Library/Screen\ Savers/Aerial.saver"; defaults -currentHost write com.apple.screensaver moduleName -string "Aerial";defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Aerial path ~/Library/Screen\ Savers/Aerial.saver type 0;
defaults -currentHost write com.apple.screensaver modulePath -string "~/Library/Screen\ Savers/$screensaver"; defaults -currentHost write com.apple.screensaver moduleName -string "Aerial";defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Aerial path ~/Library/Screen\ Savers/$screensaver type 0;
osascript -e 'display notification "Installed for this user only, enjoy." with title "Success, Aerial Desktop"'
elif [ -d /Library/Screen\ Savers/Aerial.saver ] ; then
defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Aerial path /Library/Screen\ Savers/Aerial.saver type 0
elif [ -d /Library/Screen\ Savers/$screensaver ] ; then
defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName Aerial path /Library/Screen\ Savers/$screensaver type 0
osascript -e 'display notification "Installed for all users, enjoy." with title "Success, Aerial Desktop"'
else
else
osascript -e 'display notification "Did you put your credentials? Uninstall and reinstall, thanks." with title "error 333 Aerial Desktop"'
fi
Loading

0 comments on commit 317b8a8

Please sign in to comment.