forked from jdpedersen1/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.sh
executable file
·147 lines (133 loc) · 4.25 KB
/
schedule.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
##----------------##
# assign variables #
##----------------##
DAY=$(date --date="2 days" | awk '{ print $2 $3 }')
TO_ADDRESS="yourmail@maildomain.com"
SUBJECT="Appointment"
BODY=$(less "$HOME/.local/todo/$DAY")
FILE="$HOME/.local/todo/$DAY"
time="$(date "+%H:%M:%S")"
#if [[ "$time" == "08:00:00" ]] && [[ -f "$FILE" ]]
#then
# echo "$BODY" | neomutt -s "$SUBJECT" "$TO_ADDRESS"
# curl -X POST https://textbelt.com/text --data-urlencode phone='xxxxxxxxxx' --data-urlencode message="$BODY" -d key=textbelt
# exit
#elif [[ "$time" != "08:00:00" ]] && [[ "$time" < "0:8:00:02" ]] && [[ ! -f "$FILE" ]]
#then
# exit
#else
#
# checks for figlet on system and installs on arch or debian based systems if not found #
# prints out header for program #
##-------------------------------------------------------------------------------------##
while true; do
if command -v figlet &> /dev/null
then
break
else
if command -v pacman &> /dev/null
then
sudo pacman -S figlet
break
elif command -v apt &> /dev/null
then
sudo apt install figlet
break
elif command -v xbps-install &> /dev/null
then
sudo xbps-install figlet
break
else
printf "please install figlet"
exit
fi
fi
done
clear
figlet -c -f slant "To Do"
figlet -s -f digital "A simple terminal appointment organizer"
printf "\n "
printf " created by: Jake Pedersen of Jake@Linux\n"
printf "\n "
##--------------------------------------------------------------------##
# prompts for user input and checks for action user wishes to complete #
##--------------------------------------------------------------------##
while true; do
printf "Please Make a Selection\n(options: A/a=add, V/v=view, & E/e=exit)\n"
printf " : "
read -r answer
##-------------------------------------------------##
# prompts for appointment info if "add" is selected #
##-------------------------------------------------##
if [[ "$answer" == [A/a] ]]
then
printf "\n"
printf "Date\n(format = Dec12)"
printf "\n : "
read -r date
printf "\n"
printf "Time\n(format = HH:MM AM/PM) "
printf "\n : "
read -r time
printf "\n"
printf "Entry\n "
printf "\n : "
read -r entry
##---------------------------------------------------------------------##
# checks for file with selected date, if found, stores new appointment, #
# if not found, it creates new file #
##---------------------------------------------------------------------##
if [[ -f "$HOME/.local/todo/$date" ]]; then
printf '%s %s :\n %s\n\n' "$date" "$time" "$entry" >> "$HOME/.local/todo/$date"
vim "$HOME/.local/todo/$date"
else
touch "$HOME/.local/todo/$date"
figlet -s -f slant "$date" >> "$HOME/.local/todo/$date"
printf '%s %s :\n %s\n\n' "$date" "$time" "$entry" >> "$HOME/.local/todo/$date"
vim "$HOME/.local/todo/$date"
fi
##-----------------------------------------------------------------------------##
# if "view" selected, prompts user for which date to view or all, if date given #
# opens file for given date, if all selected, opens dir of all files for user #
# to choose from, if exit chosen, closes program #
##-----------------------------------------------------------------------------##
elif [[ "$answer" == [V/v] ]]
then
printf "\n"
printf "Please type \"date\" or \"all\" to choose from list"
printf "\n : "
read -r choice
printf "\n"
if [[ "$choice" == all ]]
then
ls "$HOME/.local/todo/"
else
if [[ "$choice" == date ]]
then
printf "Which date would you like to view?\n"
printf "(format = Dec12)"
printf "\n : "
read -r day
vim "$HOME/.local/todo/$day"
fi
fi
elif [[ "$answer" == [E/e] ]]
then
exit
else [[ "$answer" == ? ]]
printf "Please make proper selection"
fi
printf "\nWould you like to add or view another entry?\n"
printf "(Y/y or N/n)"
printf "\n: "
read -r decision
printf "\n"
if [[ "$decision" == [Y/y] ]]
then
printf "Great!\n"
else
exit
fi
done
#fi