-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·51 lines (43 loc) · 1.05 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
CYAN='\x1B[0;36m'
YEL='\x1B[0;33m'
RED='\x1B[0;31m'
NC='\x1B[0m' # No Color
YT_PROMPTED="n"
tryPromptforYtVideo(){
if [ "$YT_PROMPTED" = "y" ]; then
return
fi
YT_PROMPTED="y"
echo "${YEL}Do you want to open a Youtube video so your mac will stay awake and discharge faster?${NC}"
echo "Enter Y/y/n/N and press ENTER"
read openYtVideo
if [ "$openYtVideo" = "y" ] || [ "$openYtVideo" = "Y" ]; then
echo "${CYAN} Opening a video in Safari.. ${NC}"
open -a Safari https://www.youtube.com/watch?v=4dhIvyskkB0
elif [ "$openYtVideo" = "n" ] || [ "$openYtVideo" = "N" ]; then
return
fi
}
if [ "$EUID" -ne 0 ]
then echo "Please run as root."
exit
fi
while true
do
output=`pmset -g batt`
for i in {10..15}
do
if [[ $output == *"$i%"* ]]; then
echo "Shutting down. Battery in reserve."
shutdown -h now
fi
done
log=`echo $output|grep -i discharging`
tryPromptforYtVideo
echo "${CYAN}>>Watching...battery reserve yet to be met.${NC}"
echo $log
echo
echo
sleep 5
done