-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain2.sh
More file actions
executable file
·330 lines (291 loc) · 12.5 KB
/
main2.sh
File metadata and controls
executable file
·330 lines (291 loc) · 12.5 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/bin/bash
# Declare an array to save PIDs
declare -a pids
show_logo() {
cat << "EOF"
▗▄▄▖▗▄▄▄▖▗▖ ▗▖▗▄▄▄▗▖ ▗▖▗▄▖ ▗▄▄▖ Made By: Hamdi Awad
▐▌ █ ▐▌ ▐▌▐▌ █▝▚▞▘▐▌ ▐▌▐▌ Omar Walid
▝▀▚▖ █ ▐▌ ▐▌▐▌ █ ▐▌ ▐▌ ▐▌ ▝▀▚▖ Omar Abdelrady
▗▄▄▞▘ █ ▝▚▄▞▘▐▙▄▄▀ ▐▌ ▝▚▄▞▘▗▄▄▞▘
EOF
}
show_info() {
cat << INFO
▗▄▄▖▗▄▄▄▖▗▖ ▗▖▗▄▄▄▗▖ ▗▖▗▄▖ ▗▄▄▖ Made By: Hamdi Awad
▐▌ █ ▐▌ ▐▌▐▌ █▝▚▞▘▐▌ ▐▌▐▌ Omar Abdulaal
▝▀▚▖ █ ▐▌ ▐▌▐▌ █ ▐▌ ▐▌ ▐▌ ▝▀▚▖ Omar Abdalrady
▗▄▄▞▘ █ ▝▚▄▞▘▐▙▄▄▀ ▐▌ ▝▚▄▞▘▗▄▄▞▘
System Information:
=========================
Hostname: $(hostname)
Kernel: $(uname -r)
CPU: $(grep -m 1 'model name' /proc/cpuinfo | cut -d':' -f2 | xargs)
Memory Usage: $(free -h | grep Mem | awk '{print $3 "/" $2}')
Disk Usage: $(df -h --total | grep total | awk '{print $3 "/" $2}')
Operating System: $(lsb_release -d | cut -f2)
Uptime: $(uptime -p)
=========================
INFO
}
assignment_manager() {
# Course Assignment
C_SOURCE="assignment_courses.c"
C_BINARY="./assignment_courses"
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
TITLE="Course Management System"
MENU="Choose an option:"
# Variables Assignment
CHOICE_HEIGHT2=5
TITLE2="Assignment Management System"
# Dialog Course menu options
OPTIONS2=(
1 "Show existing Courses"
2 "Add Course"
3 "Delete Course"
4 "Check Assignments"
)
# Dialog Assignment menu options
OPTIONS3=(
1 "View All Assignments"
2 "View Course Assignments"
3 "Add Assignment"
4 "Submit Assignment"
5 "Delete Assignment"
)
# Courses loop
while true;
do
choice=$(dialog --clear \
--title "$TITLE" \
--ok-label "Proceed" \
--cancel-label "Back to StudyOS" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS2[@]}" \
2>&1 >/dev/tty)
clear
case $choice in
1)
# View All Courses
OUTPUT=$($C_BINARY "1")
dialog --msgbox "$OUTPUT" 20 80
;;
2)
dialog --msgbox "Adding a Course" 6 50
clear
COURSE_NAME=$(dialog --inputbox "Enter course name:" 10 40 2>&1 >/dev/tty)
clear
if [[ -n "$COURSE_NAME" ]]; then
$C_BINARY 2 "$COURSE_NAME"
dialog --msgbox "Course '$COURSE_NAME' added successfully!" 10 40
else
dialog --msgbox "All fields are required to add an assignment." 10 40
fi
;;
3)
OUTPUT=$($C_BINARY "1")
dialog --msgbox "$OUTPUT" 20 80
COURSE_ID=$(dialog --inputbox "Enter course ID:" 10 40 2>&1 >/dev/tty)
if [[ "$COURSE_ID" =~ ^[1-9][0-9]*$ ]]; then
$C_BINARY 3 $COURSE_ID
dialog --msgbox "Course '$COURSE_ID' deleted successfully!" 10 40
else
dialog --msgbox "Course ID is required to be a positive number." 10 40
fi
;;
4)
exit_loop=true
while $exit_loop
do
CHOICE=$(dialog --clear \
--title "$TITLE2" \
--ok-label "Proceed" \
--cancel-label "Back to Courses" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT2 \
"${OPTIONS3[@]}" \
2>&1 >/dev/tty)
clear
if [ $? -eq 1 ]; then
echo "Returning to Courses Menu..."
# You can call another function or menu here instead of breaking
exit_loop=false
fi
case $CHOICE in
1) # View All Assignments
OUTPUT=$($C_BINARY "4" "1")
dialog --msgbox "$OUTPUT" 20 80
;;
2) # View Course Assignments
COURSE_ID=$(dialog --inputbox "Enter course ID:" 10 40 2>&1 >/dev/tty)
if [[ "$COURSE_ID" =~ ^[1-9][0-9]*$ ]]; then
OUTPUT=$($C_BINARY "4" "2" "$COURSE_ID")
dialog --msgbox "$OUTPUT" 20 80
else
dialog --msgbox "Course ID is required to view assignments." 10 40
fi
;;
3) # Add Assignment
COURSE_ID=$(dialog --inputbox "Enter course ID:" 10 40 2>&1 >/dev/tty)
ASSIGNMENT_NAME=$(dialog --inputbox "Enter assignment name:" 10 40 2>&1 >/dev/tty)
DIFFICULTY=$(dialog --inputbox "Enter difficulty level (1-10):" 10 40 2>&1 >/dev/tty)
TIME_REQUIRED=$(dialog --inputbox "Enter estimated time (hours):" 10 40 2>&1 >/dev/tty)
DUE_DATE=$(dialog --calendar 'Enter Due Date' 5 50 1 1 2025 2>&1 >/dev/tty)
clear
if [[ "$COURSE_ID" && "$DIFFICULTY" && "$TIME_REQUIRED" =~ ^[1-9][0-9]*$ && -n "$DUE_DATE" && -n "$ASSIGNMENT_NAME" ]]; then
$C_BINARY 4 3 "$COURSE_ID" "$ASSIGNMENT_NAME" "$DIFFICULTY" "$TIME_REQUIRED" "$DUE_DATE"
dialog --msgbox "Assignment '$ASSIGNMENT_NAME' added successfully!" 10 40
else
dialog --msgbox "All fields are required to be vaild to add an assignment." 10 40
fi
;;
4) # Submit Assignment
COURSE_ID=$(dialog --inputbox "Enter course ID:" 10 40 2>&1 >/dev/tty)
ASSIGNMENT_ID=$(dialog --inputbox "Enter assignment ID:" 10 40 2>&1 >/dev/tty)
if [[ "$ASSIGNMENT_ID" && "$COURSE_ID" =~ ^[1-9][0-9]*$ ]]; then
dialog --msgbox "Select the Text file from popup to submit." 10 40
FILE_PATH=$(zenity --file-selection --title="Select Text File" --file-filter="*.txt" 2>/dev/null)
$C_BINARY 4 4 "$COURSE_ID" "$ASSIGNMENT_ID" "$FILE_PATH"
dialog --msgbox "Assignment '$ASSIGNMENT_ID' submitted successfully!" 10 40
else
dialog --msgbox "Course ID and Assignment ID is required tobe valid to submit an assignment." 10 40
fi
clear
;;
5) # Delete Assignment
COURSE_ID=$(dialog --inputbox "Enter course ID:" 10 40 2>&1 >/dev/tty)
ASSIGNMENT_ID=$(dialog --inputbox "Enter assignment ID:" 10 40 2>&1 >/dev/tty)
if [[ "$ASSIGNMENT_ID" && "$COURSE_ID" =~ ^[1-9][0-9]*$ ]]; then
$C_BINARY 4 5 "$COURSE_ID" "$ASSIGNMENT_ID"
dialog --msgbox "Assignment '$ASSIGNMENT_ID' deleted successfully!" 10 40
else
dialog --msgbox "Course ID and assignment ID are required to delete an assignment." 10 40
fi
clear
;;
*) # Invalid choice
break
;;
esac
done
;;
*)
clear
return
;;
esac
done
}
gpa_manager() {
while true; do
COURSES_COUNT=$(dialog --inputbox "Enter the number of subjects:" 10 30 2>&1 >/dev/tty)
if [[ "$COURSES_COUNT" =~ ^[1-9][0-9]*$ ]]; then
break
else
dialog --msgbox "Please enter a valid positive integer for the number of subjects." 10 30
fi
done
if [ -z "$COURSES_COUNT" ]; then
dialog --msgbox "Number of subjects cannot be empty" 10 30
exit 1
fi
echo "" > subject_data.txt
for (( i=1; i<=$COURSES_COUNT; i++ ))
do
credit_hours=$(dialog --inputbox "Enter credit hours for subject $i:" 10 30 2>&1 >/dev/tty)
grade=$(dialog --menu "Choose grade for subject $i:" 15 30 10 \
"4.0" A+ "4.0" A "3.7" A- "3.3" B- "3.0" B "2.7" B- \
"2.3" C+ "2.0" C "1.7" C- "1.3" D "1.0" D- "0.0" F 2>&1 >/dev/tty)
echo "$credit_hours $grade" >> subject_data.txt
clear
done
./gpa_out $COURSES_COUNT subject_data.txt
rm -f subject_data.txt
}
USER_NAME=$(logname)
cd /home/$USER_NAME/Documents/StudyOS/applications
HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=6
TITLE="Main Menu"
MENU="Choose an option:"
OPTIONS=(
1 "Pomodoro Timer"
2 "Course and Assignment Manager"
3 "Music Player"
4 "PC Info"
5 "GPA Calculator"
)
while true; do
CHOICE=$(dialog --clear \
--title "$TITLE" \
--ok-label "Proceed" \
--cancel-label "Exit StudyOS" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
# Clear the screen
clear
# Handle user choice
case $CHOICE in
1)
while true; do
work_input=$(dialog --clear \
--backtitle "StudyOS - Hamdi Awad, Omar Abdulaal, Omar Abdulrady" \
--title "Work Session Time" \
--inputbox "Please Enter Work Session Time In Minutes:" 8 40 \
--output-fd 1)
if [[ "$work_input" =~ ^[0-9]+$ ]]; then
break
else
dialog --msgbox "Please enter a valid number for work session time." 10 40
fi
done
while true; do
break_input=$(dialog --clear \
--backtitle "StudyOS - Hamdi Awad, Omar Abdulaal, Omar Abdulrady" \
--title "Break Session Time" \
--inputbox "Please Enter Break Session Time In Minutes:" 8 40 \
--output-fd 1)
if [[ "$break_input" =~ ^[0-9]+$ ]]; then
break
else
dialog --msgbox "Please enter a valid number for break session time." 10 40
fi
done
clear
gnome-terminal -- ./pomodoro $work_input $break_input &
pids+=($!)
;;
2)
assignment_manager
clear
;;
3)
gnome-terminal -- ./sound_player.sh &
pids+=($!)
;;
4)
temp_file=$(mktemp)
show_info > "$temp_file"
dialog --textbox "$temp_file" 20 70
rm -f "$temp_file"
;;
5)
gpa_manager
clear
;;
*)
temp_logo=$(mktemp)
show_logo > "$temp_logo"
dialog --textbox "$temp_logo" 10 70
rm -f "$temp_file"
kill -9 "${pids[@]}"
clear
exit 0
;;
esac
done