-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·756 lines (692 loc) · 24 KB
/
run.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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
#!/bin/bash
#license info to add
#TODO:
#get ret on all buttons
#for version 0.2
#try to optimize playback for mplayer
#create log -> NEED TO DEFINE SCOPE OF THE LOG
#put checkboxes to clarify what is opened or not > DONE
#capture logged in info from coursera-dl and pipe it > HALF DONE
#display megabytes in zenity download bar if possible > DONE
#check online connectivity > DRAFTED, SEE IF IT WORKS
#add jumanji and let user open course in browser
#add launcher for libreoffice if available
#add version number variable # DRAFTED, need to be checked again
#EN PLUS...
#add duration of each video and create a file with the video name that has the time value
#save position in mplayer playback if possible
#add auto updater for coursera-dl - need git??
#automatically check if updated videos are available?
#add what is coursera entry in the menu
#add option to open excel files and word and ppt files in libreoffice
#try to add preview function
#add PC mode, not just Pandora, as well as system detection - see if $yad="./yad" or yad works -STARTED
#note sur Geometry
#The WIDTH and HEIGHT parts of the geometry specification are usually measured in either pixels or characters, depending on the application. The XOFF and YOFF parts are measured in pixels and are used to specify the distance of the window from the left or right and top and bottom edges of the screen, respectively. Both types of offsets are measured from the indicated edge of the screen to the corresponding edge of the window. The X offset may be specified in the following ways:
#+XOFF
#The left edge of the window is to be placed XOFF pixels in from the left edge of the screen (i.e., the X coordinate of the window's origin will be XOFF). XOFF may be negative, in which case the window's left edge will be off the screen.
#-XOFF
#The right edge of the window is to be placed XOFF pixels in from the right edge of the screen. XOFF may be negative, in which case the window's right edge will be off the screen.
#The Y offset has similar meanings:
#+YOFF
#The top edge of the window is to be YOFF pixels below the top edge of the screen (i.e., the Y coordinate of the window's origin will be YOFF). YOFF may be negative, in which case the window's top edge will be off the screen.
#-YOFF
#The bottom edge of the window is to be YOFF pixels above the bottom edge of the screen. YOFF may be negative, in which case the window's bottom edge will be off the screen.
#Offsets must be given as pairs; in other words, in order to specify either XOFF or YOFF both must be present. Windows can be placed in the four corners of the screen using the following specifications:
#+0+0
#upper left hand corner.
#-0+0
#upper right hand corner.
#-0-0
#lower right hand corner.
#+0-0
#lower left hand corner.
#Initial parameters
showvideoonly="no" #confirms if only the videos are displayed in the list of content
icon="--window-icon=icon.png" #icon used for yad windozs
version=0.4 #version number
globalcoursesfolder="COURSES"
downloading="False"
heightwindow=325 #to check standards
widthwindow=700 #to check standards
positionning="--center"
signaldownload()
{
if [ ! -f "tmp/downloading" ]; then
touch "tmp/downloading"
fi
}
downloadingcheck()
{
if [ ! -f "tmp/downloading" ]; then
downloading="False"
positionning="--center"
else
downloading="True"
positionning="--geometry=700x325+50+50"
fi
}
loadglobalcoursesfoldervariable()
{
#load the text file it it exists and default to COURSES otherwise
echo "yo man"
}
changefolder()
{
$globalcoursesfolder=$yadcall --file --directory
#put stuff here to change folder
#save folder in text file
}
creditsfile()
{
#to create a new credits text file to be used by credits function - TO TEST
if [ ! -f "creditsnew.txt" ]; then
credits="Courserian by Ekianjo - Version "$version"\nUsing Coursera-dl and Yad\nFirst released in 2013 for the Alive and Kicking Coding Competition"
printf "$credits" > creditsnew.txt
else
credits=$(cat creditsnew.txt)
if [[ "$credits" == *$version* ]]; then
echo "the file is cool, contains the right credits info"
else
credits="Courserian by Ekianjo \n Version \n "$version""
printf "$credits" > creditsnew.txt
fi
fi
}
#to be used for logging activity within courserian
timerstart()
{
START=$(date +%s.%N)
}
timerstop()
{
END=$(date +%s.%N)
#DIFF=$(echo "$END - $START" | bc)
}
#need to test if this works
checkonline()
{
#found on https://stackoverflow.com/questions/17291233/how-to-check-internet-access-using-bash-script-in-linux
wget -q --tries=10 --timeout=20 -O - http://google.com > /dev/null
if [[ $? -eq 0 ]]; then
online="on"
echo "online status is $online"
else
online="off"
echo "online status is $online"
$yadcall --title="Courserian" --borders=10 --width=400 --button="gtk-ok:0" --text="You are currently offline. Please get online in order to download new course material." "$icon" --on-top
fi
}
#need to test if this works
desktoporpandora()
{
if [ ! -d "/usr/pandora/" ]; then
runningmachine="desktop"
yadcall="yad"
echo "you are running Courserian on desktop"
else
runningmachine="pandora"
yadcall="./yad"
echo "you are running Courserian on Pandora"
locatesmplayer
fi
}
#not sure if it works, to try
previewvideo()
{
mplayer -ontop -zoom -x 500 -y 300 -geometry 30%:30% video_file &
}
quitprocedure()
{
if [ "$runningmachine" == "pandora" ] ; then
if [ "$smplayerison" == "yes" ] ; then
#unmount the SMPlayer PND if used
/usr/pandora/scripts/pnd_run.sh -p "$smplayerlocation" -b "smplayer" -u &
smplayerison="no"
fi
fi
exit 0
}
updatecourselist() #updates the course list visible to the user
{
listofcourses=""
totalcourses=0
sizeoffolder=0
cd COURSES #goes in the COURSES folder where courses are stored
for i in $(ls -d */) #for each directory i found in that folder...
do
totalcourses=$(( $totalcourses + 1 ))
i=$(echo $i | awk 'BEGIN {FS="/" } { print $1 }') #reduces the path to the folder name
sizeoffolder=$(du -sh "$i" | cut -f 1)
#sizeoffolder=$((sizeoffolder / 2**20))
listofcourses+="$i $sizeoffolder " #prepared for display in yad as list with 2 columns
echo "$listofcourses"
done
cd ..
echo $listofcourses
if [ -f "lastfolder.txt" ]; then
lastfolder=$(head -n 1 lastfolder.txt)
else
lastfolder=""
fi
}
locatesmplayer()
{
if [ -f "smplayerlocation.txt" ] ; then
smplayerlocation=$(head -n 1 smplayerlocation.txt)
/usr/pandora/scripts/pnd_run.sh -p "$smplayerlocation" -b "smplayer" -m
smplayerison="yes"
echo "$smplayerlocation"
else
"" > smplayerlocation.txt ##probably should not actually create the file!!!
fi
}
#browserlocation="/media/nite_ordina/pandora/menu/qupzilla.pnd"
#/usr/pandora/scripts/pnd_run.sh -p "$browserlocation" -b "qupbrowser" -m
#/usr/pandora/scripts/pnd_run.sh -p "$smplayerlocation" -m
coursesfolder()
{
#Startup script create courses folder
if [ ! -d "COURSES" ]; then
mkdir "COURSES" #creates folder for first time if not there
fi
if [ ! -d "tmp" ]; then
mkdir "tmp" #creates temp folder for first time if not there
fi
}
firststartcheck()
{
#first message. Ideally should not appear twice. to test if it works
if [ ! -f "firststart.txt" ] ; then
#./yad --title="Courserian" --borders=10 --width=500 --button="gtk-ok:0" --text="Welcome to Courserian. Courserian is a tool to make it easy for you to download, browse and manage your Coursera lessons." "$icon" --on-top
$yadcall --title="Courserian" --borders=10 --width=400 --button="gtk-ok:0" --text="Welcome to Courserian. Courserian is a tool to make it easy for you to download, browse and manage your Coursera lessons." "$icon" --on-top
touch "firststart.txt" #should create a file without content
fi
}
startupscript()
{
courseentry="Remove/delete a course"
browsecourse="Browse your courses"
updatecourse="Download/update your courses"
#last folder function does not work somehow...
if [ -f "lastfolder.txt" ]; then
lastfolder=$(head -n 1 lastfolder.txt)
else
lastfolder=""
fi
echo "$lastfolder"
#test for login
if [ -f "login.txt" ] && [ -f "password.txt" ]; then
login=$(head -n 1 login.txt)
password=$(head -n 1 password.txt)
loginentry="Modify your Login details"
else
login=""
password=""
loginentry="Enter your Login details"
fi
}
menu()
{
if [ "$login" != "" ]; then
menutitle="Menu [ $login ]" #display your porfile name is login is registered
else
menutitle="Menu"
fi
#echo "$menutitle"
downloadingcheck #checks if positionning needs to be alterered
if [ $totalcourses -eq 0 ] ; then
choice=$($yadcall "$positionning" --width=700 --borders=5 --height=325 --title="Courserian" --list --column="$menutitle" "$loginentry" "Add a course to follow" "Credits" --image="coursera-small.png" --image-on-top "$icon" --button="gtk-quit:1" --on-top)
else
#if [ "$lastfolder" != "" ]; then
#choice=$(./yad --center --width=300 --borders=5 --height=330 --title="Courserian" --list --column="$menutitle" "$loginentry" "Add a course to follow" "$courseentry" "Last working folder" "$browsecourse" "$updatecourse" "Extras" "Credits" --image="coursera-small.png" --image-on-top --button="gtk-quit:1" "$icon" --on-top)
#else
#Need to ADD CONDITION FOR DESKTOP AND PANDORA DIFFERENCES
choice=$($yadcall --center --width=300 --borders=5 --height=330 --title="Courserian" --list --column="$menutitle" "$loginentry" "Add a course to follow" "$courseentry" "$browsecourse" "$updatecourse" "Extras" "Credits" --image="coursera-small.png" --image-on-top --button="gtk-quit:1" "$icon" --on-top)
#fi
fi
ret=$?
if [ $ret -eq 1 ] ; then
quitprocedure
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "Add a course to follow" ]; then
addingcourse
fi
if [ "$choice" == "Last working folder" ]; then #not working yet
set -- "$lastfolder"
IFS="/"; declare -a Array=($*)
currentfolder="${Array[1]}"
currentfolder=${currentfolder/$'\n'/}
materialfolder="${Array[2]}"
echo "$currentfolder"
currentfolder="romanarchitecture-001"
#echo "$materialfolder"
#explorematerials
explorefolder
fi
if [ "$choice" == "Enter your Login details" ] || [ "$choice" == "Modify your Login details" ]; then
login
fi
if [ "$choice" == "Extras" ]; then
extrasmenu
fi
if [ "$choice" == "Remove/delete a course" ]; then
mode="delete"
showcourses
fi
if [ "$choice" == "Browse your courses" ]; then
showcourses
fi
if [ "$choice" == "Download/update your courses" ]; then
updatecourselist
if [ "$login" != "" ] && [ "$password" != "" ]; then
downloadcoursemenu
else
warnlogindetails
menu
fi
fi
if [ "$choice" == "Credits" ]; then
#./yad --center --width=380 --borders=5 --height=330 --title="Courserian" --image="coursera2.png" --image-on-top --list --column="Credits" "Created by Ekianjo, 2013-2014. GPL v2 License." "Uses Coursera-dl as backend, Yad for GUI." "Released for the Alive and Kicking Coding Competition" "Logo of Courserian made with ImageJ by Ekianjo" "Created on Open Pandora. Version 0.2." --button="gtk-ok" --on-top
$yadcall --center --width=380 --borders=5 --height=330 --title="Courserian" --image="coursera2.png" --image-on-top --text-info --filename=creditsnew.txt --button="gtk-ok" --on-top
menu
fi
}
warnlogindetails()
{
$yadcall --center --width=200 --borders=5 --height=80 --title="Courserian" --text="You need to first enter your login details in order to download anything." "$icon" --on-top
}
extrasmenu()
{
size=${#smplayerlocation}
if [ "$size" -lt 5 ] ; then
choice=$($yadcall --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Download courses" "[Back to main menu]" "Find SMPlayer" "$icon" --button="gtk-quit:9" --on-top)
ret=$?
if [ $ret -eq 9 ] ; then
quitprocedure
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "Find SMPlayer" ]; then
"" > smplayerlocation.txt
for i in $(ls -d /media/*/)
do
echo $i
smplayerlocation=$(head -n 1 smplayerlocation.txt)
size=${#smplayerlocation}
if [ "$size" -lt 5 ] ; then
find "$i"pandora -name smplayer2_r6.pnd > smplayerlocation.txt
fi
done
extrasmenu
fi
else
if [ "$smplayerison" == "yes" ] ; then
choice=$($yadcall --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Download courses" "[Back to main menu]" "Unmount SMPlayer" "$icon" --button="gtk-quit:9" --on-top)
ret=$?
if [ $ret -eq 9 ] ; then
quitprocedure
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "[Back to main menu]" ] ; then
menu
else
if [ "$choice" == "Unmount SMPlayer" ]; then
/usr/pandora/scripts/pnd_run.sh -p "$smplayerlocation" -b "smplayer" -u
smplayerison="no"
menu
fi
fi
else
choice=$($yadcall --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Download courses" "[Back to main menu]" "Make SMPlayer the default player" "$icon" --button="gtk-quit:9" --on-top)
ret=$?
if [ $ret -eq 9 ] ; then
quitprocedure
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "[Back to main menu]" ] ; then
menu
else
if [ "$choice" == "Make SMPlayer the default player" ]; then
echo "$smplayerlocation"
/usr/pandora/scripts/pnd_run.sh -p "$smplayerlocation" -b "smplayer" -m
smplayerison="yes"
menu
fi
fi
fi
fi
#choice=$(./yad --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Download courses" "[Back to main menu]" "Find SMPlayer" "Make SMPlayer the video player" "Unmount SMPlayer" "$icon")
#choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
#if [ "$choice" == "Unmount SMPlayer" ]; then
#size=${#smplayerlocation}
#if [ "$size" -lt 5 ] ; then
#fi
#else
#fi
#fi
#fi
#fi
}
downloadcoursemenu()
{
choice=$($yadcall --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Download courses" "[Back to main menu]" "Download/Update a single course" "Download/update all" "$icon" --button="gtk-quit:9" --button="Top Menu:5" --on-top)
ret=$?
if [ "$ret" -eq "9" ] ; then
quitprocedure
fi
if [ "$ret" -eq "5" ] ; then
menu
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "[Back to main menu]" ] ; then
menu
else
if [ "$choice" == "Download/Update a single course" ]; then
mode="download"
showcourses
else
if [ "$choice" == "Download/update all" ]; then
downloadallcourses
fi
fi
fi
}
downloadallcourses() #download all courses one after the other
{
cd COURSES
currentcourse=""
for i in $(ls -d */)
do
i=$(echo $i | awk 'BEGIN {FS="/" } { print $1 }')
$currentcourse+="$i "
done
cd ..
#checkonline
downloadsingleone
#cd COURSES
#cd ..
menu
}
showcourses()
{
addedtext=""
echo "$mode"
if [ "$mode" == "download" ] ; then addedtext="to download" ; fi
if [ "$mode" == "delete" ] ; then addedtext="to delete" ; fi
choice=$($yadcall --center --image="coursera-small.png" --image-on-top --width=300 --borders=5 --height=300 --title="Courserian" --list --column="Select a course $addedtext" --column="Folder Size" "[Back to main menu]" " " $listofcourses --button="gtk-quit:9" --button="Top Menu:5" "$icon" --on-top)
ret=$?
if [ "$ret" -eq "9" ] ; then
quitprocedure
fi
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$choice" == "[Back to main menu]" ] || [ "$ret" -eq "5" ] ; then
mode=""
menu
else
if [ "$mode" == "download" ]; then
currentcourse="$choice"
checkonline
downloadsingleone
mode=""
menu
else
if [ "$mode" == "delete" ]; then
currentcourse="$choice"
deletecourseconfirm
mode=""
menu
else
currentfolder="$choice"
explorefolder
fi
fi
fi
}
calculateduration()
{
#to test, not active yet
mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
sed -ne '/^ID_/ {
s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
}'
}
deletecourseconfirm()
{
echo "delete course confirm"
confirm=$($yadcall --center --width=200 --borders=5 --title="Courserian" --text="Are you sure you want to delete\n the course $currentcourse ?" --button="gtk-yes:0" --button="gtk-no:1" "$icon" --on-top)
ret=$?
if [[ $ret -eq 0 ]]; then
cd COURSES
rm -r "$currentcourse"
cd ..
updatecourselist
mode=""
menu
else
mode=""
menu
fi
}
explorefolder()
{
listoffolders=""
cd COURSES/"$currentfolder"
for i in $(ls -d */)
do
#echo "$i"
i=$(echo $i | awk 'BEGIN {FS="/" } { print $1 }')
#i=${i/$'\n'/}
sizeoffolder=$(du -b "$i" | cut -f 1)
sizeoffolder=$((sizeoffolder / 2**20))
listoffolders+="$i $sizeoffolder "
#listoffolders+=" "
done
cd ..
cd ..
choice=$($yadcall --center --image="coursera-long.png" --image-on-top --width=700 --borders=5 --height=350 --title="Courserian" --list --column="$currentfolder > Select a subfolder" --column="Size (Mb)" "[Back to previous menu]" " " $listoffolders --button="gtk-quit:9" --button="Top Menu:5" --button="Go Up:4" --button="Delete Folder:3" "$icon" --on-top)
ret=$?
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$ret" -eq "9" ] ; then
quitprocedure
fi
if [ "$ret" -eq "5" ] ; then
menu
fi
if [ ! "$choice" == "[Back to previous menu]" ] || [ "$ret" -eq "3" ] ; then
confirm=$($yadcall --center --width=200 --borders=5 --title="Courserian" --text="Are you sure you want to delete\n the course $choice ?" --button="gtk-yes:0" --button="gtk-no:1" "$icon" --on-top)
ret=$?
if [[ $ret -eq 0 ]]; then
rm -r "$choice"
updatecourselist
explorefolder
fi
fi
if [ "$choice" == "[Back to previous menu]" ] || [ "$ret" -eq "4" ] ; then
showcourses
else
materialfolder="$choice"
explorematerials
fi
}
explorematerials()
{
listofmaterials=""
cd COURSES/"$currentfolder"/"$materialfolder"
for file in ./*
do
if [[ -f $file ]]; then
sizeoffile=$(du -b "$file" | cut -f 1)
sizeoffile=$((sizeoffile / 2**20))
file=${file:2}
extension=${file: -3}
if [[ -f ".""$file"".read" ]]; then
viewed="Y"
else
viewed="_"
fi
if [ "$showvideoonly" == "yes" ] && [ "$extension" == "mp4" ] ; then
listofmaterials+="$file $sizeoffile $viewed "
#listofmaterials+=" "
else
if [ "$showvideoonly" == "no" ] ; then
listofmaterials+="$file $sizeoffile $viewed "
#listofmaterials+="$file"
#listofmaterials+=" "
#listofmaterials+="$sizeoffile "
fi
fi
fi
done
cd ../../..
#columntext="$currentfolder""/""$materialfolder"
materialfolderdisplay="${materialfolder//_/ }"
columntext="$currentfolder / "${materialfolderdisplay:0:50}
echo $columntext
if [ "$showvideoonly" == "no" ] ; then
buttonvideolabel="Show Videos Only"
else
buttonvideolabel="Show All files"
fi
choice=$($yadcall --image="coursera-long.png" --image-on-top --center --width=700 --borders=5 --height=350 --title="Courserian" --list --column="$columntext" --column="Size (Mb)" --column="Viewed" "[Back to previous menu]" " " " " $listofmaterials --button="gtk-quit:9" --button="$buttonvideolabel:6" --button="Top Menu:5" --button="Go Up:4" "$icon" --on-top)
ret=$?
choice=$(echo $choice | awk 'BEGIN {FS="|" } { print $1 }')
echo $choice
if [ "$ret" -eq "9" ] ; then
quitprocedure
fi
if [ "$ret" -eq "5" ] ; then menu ; fi
if [ "$ret" -eq "6" ] ; then
if [ "$showvideoonly" == "yes" ] ; then
showvideoonly="no" ;
explorematerials
else
showvideoonly="yes" ;
explorematerials
fi
fi
if [ "$choice" == "[Back to previous menu]" ] || [ "$ret" -eq "4" ] ; then
explorefolder
fi
extension=${choice: -3}
if [ "$extension" == "srt" ] || [ "$extension" == "txt" ] ; then
" " > COURSES/"$currentfolder"/"$materialfolder"/".""$choice"".read"
if [ "$runningmachine" == "pandora" ] ; then
mousepad COURSES/"$currentfolder"/"$materialfolder"/"$choice"
else
xdg-open COURSES/"$currentfolder"/"$materialfolder"/"$choice"
fi
explorematerials
fi
if [ "$extension" == "pdf" ] ; then
" " > COURSES/"$currentfolder"/"$materialfolder"/".""$choice"".read"
if [ "$runningmachine" == "pandora" ] ; then
evince -s COURSES/"$currentfolder"/"$materialfolder"/"$choice"
else
xdg-open COURSES/"$currentfolder"/"$materialfolder"/"$choice"
fi
explorematerials
fi
if [ "$extension" == "mp4" ] ; then
" " > COURSES/"$currentfolder"/"$materialfolder"/".""$choice"".read"
if [ "$runningmachine" == "pandora" ] ; then
if [ "$smplayerison" == "yes" ] ; then
"COURSES/$currentfolder/$materialfolder" > lastfolder.txt
/mnt/utmp/smplayer/bin/mplayer -ss 14 -framedrop -vo omapfb -autoq 6 -fs -nocache COURSES/"$currentfolder"/"$materialfolder"/"$choice" > out.txt
#/mnt/utmp/smplayer2_r6/bin/smplayer2 COURSES/"$currentfolder"/"$materialfolder"/"$choice"
#else
#mplayer/bin/mplayer -vo sdl -autoq 3 -nocache -fs -framedrop COURSES/"$currentfolder"/"$materialfolder"/"$choice"
else
echo "COURSES/$currentfolder/$materialfolder" > lastfolder.txt
mplayer -fs -framedrop -vo sdl COURSES/"$currentfolder"/"$materialfolder"/"$choice"
fi
else
xdg-open COURSES/"$currentfolder"/"$materialfolder"/"$choice"
fi
explorematerials
fi
if [ "$extension" == "ptx" ] ; then
explorematerials
fi
}
#LOGIN / PASSWORD
login()
{
dialog=$($yadcall --center --borders=10 --title="Login Details" --form --field="Coursera Login" --text="Login info will be saved locally" --field="Password":H "$icon" --on-top)
login=$(echo $dialog | awk 'BEGIN {FS="|" } { print $1 }')
password=$(echo $dialog | awk 'BEGIN {FS="|" } { print $2 }')
#save them to text file
echo $login
echo $password
if [ $login != "" ]; then
if [ $password != "" ]; then
loginentry="Modify your Login details"
echo $login > login.txt
echo $password > password.txt
fi
else
loginentry="Enter your Login details"
fi
menu
}
addingcourse()
{
#ADDING A COURSE
entry=$($yadcall --width=400 --center --borders=10 --title="Courserian" --text="Enter the course code you wish to add.\n You can find this code or short name in the URL of your course.\n For example..." --form --field="Course Name" "$icon" --on-top)
entry=$(echo $entry | awk 'BEGIN {FS="|" } { print $1 }')
if [ "$entry" != "" ]; then
downloadsingle
else
updatecourselist
menu
fi
}
#write it in currentcourse
#write it to a text file as well for courses
#make backup of the file
downloadsingle()
{
#-> after adding a course, confirm if user wants to download the associated material
answer=$($yadcall --width=350 --center --borders=10 --title="Courserian" --text="You have just added the course $entry in Courserian,\n would you like to download the course contents right now ?\n\n Note that you need to have accepted the code of Honor\n for that particular course on the Coursera website first." --button="gtk-yes:0" --button="gtk-no:1" "$icon" --on-top)
ret=$?
echo "$ret"
if [[ $ret -eq 0 ]]; then
currentcourse="$entry"
echo $ret
#checkonline
downloadsingleone
updatecourselist
menu
else
mkdir COURSES/"$entry"
updatecourselist
#need to register somehwere the ones to download later
menu
fi
}
splashscreen()
{
$yadcall --width=380 --height=140 --image="coursera-large.png" --undecorated --no-buttons --borders=5 --timeout=3 --timeout-indicator=bottom --image-on-top "$icon" --on-top
}
#DOWNLOAD single coursepython
downloadsingleone()
{
checkonline
if [ $online == "on" ]; then
echo $currentcourse > currentcourse.txt
python tracker.py & #this script takes care of displaying the progress bar. Not sure how I can do it the same way in bash...
fi
}
#FULL PROGRAM FLOW BELOW---------------------------------------
#pandora specific for drivers (not sure if it actually makes much difference)
export SDL_VIDEODRIVER="omapdss"
export SDL_OMAP_LAYER_SIZE="fullscreen"
creditsfile
desktoporpandora
coursesfolder
updatecourselist
firststartcheck
startupscript
#./yad --width=380 --height=140 --image="coursera-large.png" --undecorated --no-buttons --borders=5 --timeout=3 --timeout-indicator=bottom --image-on-top "$icon" --on-top
splashscreen
menu