Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A bash script to keep a list of homework todo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Jeedo
Apprentice
Apprentice


Joined: 02 May 2003
Posts: 202
Location: Akureyri, Iceland

PostPosted: Wed Oct 08, 2003 7:50 pm    Post subject: A bash script to keep a list of homework todo Reply with quote

What follows is a solution which i designed for myself to keep a list of
homework i should do for school, Placed under documentation because
thats the best catagory i could find for it

First:

Code:

emerge xcalendar



Then run the XCalendar program, this will create a ~/Calendar directory, now you can click on some day and write for example:


Code:

() Math: read page 20 in mathbook

and when you're done doing that reaplace it with

Code:

(X) Math: read page 20 in mathbook


Now i made a script which parses all that. it's kinda buggy, and has many TODO's but i just want to shere it here because i certanly can find use for it

Code:

#! /bin/bash
#   XCTFP -X Calendar Text File Parser - Parses files that X Calendar creates and makes a todo list based on them
#        Copyright (C) 2003  Ævar Arnfjörð Bjarmason

#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.

#todo: add code that deletes the full path from the output, cut should do
#todo: add code that counts every todo list, picks the largest one and prints: Thing to do next *biglist*
#todo: arrange the lists in alphabetical order (can this even be done?) - maybe with 'sort'
#todo: add events as well, like meetings and sutch and seperate them from the studying
#todo: add list for upcomming tests
#variables

calendar="/home/jeedo/Calendar"         #path to calendar files

finish="(X)"    #sets what set of character are used to mark something as finished
remain="()"     #sets what set of character are used to mark something as remaining

#events="(-)"   #things that will happen in the nearby future
#eventsf="(Y)"

echo Finished: `grep "${finish}" ${calendar}/xc* | wc -l`
grep "${finish}" ${calendar}/xc*        #add some code here that cuts out these ugly paths
echo

echo Remaining: `grep "${remain}" ${calendar}/xc* | wc -l`
grep "${remain}" ${calendar}/xc*        #| cut -d 'x' -f2 #add some code here that cuts out these ugly paths
echo

echo By courses:                                                               #space here because the output from wc begins with a \t
#this is a list of all the things i do at school, Stærðfræði is for example Math, replace or delete lines to fit your own language
echo Alma:              `grep "${finish} Alma"          ${calendar}/xc* | wc -l` / `grep "${remain} Alma"               ${calendar}/xc* | wc -l`
echo Danska:            `grep "${finish} Danska"        ${calendar}/xc* | wc -l` / `grep "${remain} Danska"             ${calendar}/xc* | wc -l`
echo Félagsfræði:       `grep "${finish} Félagsfræði"   ${calendar}/xc* | wc -l` / `grep "${remain} Félagsfræði"        ${calendar}/xc* | wc -l`
echo Íslenska:          `grep "${finish} Íslenska"      ${calendar}/xc* | wc -l` / `grep "${remain} Íslenska"           ${calendar}/xc* | wc -l`
echo Íþróttir:          `grep "${finish} Íþróttir"      ${calendar}/xc* | wc -l` / `grep "${remain} Íþróttir"           ${calendar}/xc* | wc -l`
echo Lífsleikni:        `grep "${finish} Lífsleikni"    ${calendar}/xc* | wc -l` / `grep "${remain} Lífsleikni"         ${calendar}/xc* | wc -l`
echo Stærðfræði:        `grep "${finish} Stærðfræði"    ${calendar}/xc* | wc -l` / `grep "${remain} Stærðfræði"         ${calendar}/xc* | wc -l`
echo Þýska:             `grep "${finish} Þýska"         ${calendar}/xc* | wc -l` / `grep "${remain} Þýska"              ${calendar}/xc* | wc -l`
                #this counts done/remaining not   done/done+remaining like it should, fix it , make a call to bc like: echo "1+1" | bc -l
echo
#echo "`grep "${finish} Þýska" ${calendar}/xc* | wc -l`+`grep "${remain} Þýska" ${calendar}/xc* | wc -l`" | bc -L



#echo Total: `grep "(" ${calendar}/xc* | grep ")" | wc -l` #adda ( og ) í eitt með sviga
echo Total:             `grep "[(-)]" ${calendar}/xc* | wc -l`  #seems to be working 100% but retain the above line in case of trauble
echo Script Length:     `grep -v "^#" ${calendar}/todo | grep -v "^$" | wc -l` lines ";" Comments: `grep "^#" ${calendar}/todo |  wc -l` lines


And finally here is some example output

Quote:

Finished: 6
/home/jeedo/Calendar/xc10Oct2003:(X) Stærðfræði: og 2.1A 1-7
/home/jeedo/Calendar/xc10Oct2003:(X) Danska: Finna 3 hluti til að tala um í 2min samtale
/home/jeedo/Calendar/xc10Oct2003:(X) Félagsfræði: klára að lesa 1 og 3ja kafla og gera verkefni.
/home/jeedo/Calendar/xc10Oct2003:(X) Íslenska: Lesa 7-22 og 104 í hagnýt skrif, og þarf ekki að koma m. kýrhausinn
/home/jeedo/Calendar/xc2Oct2003:(X) Þýska: glósa bls 8 og lesa bls 16 í vinnubók
/home/jeedo/Calendar/xc3Oct2003:(X) Íslenska: Gera verkefni 10 í kýrhausinn.

Remaining: 19
/home/jeedo/Calendar/xc10Oct2003:() Alma: hitta ölmu í hádeginu
/home/jeedo/Calendar/xc10Oct2003:() Þýska: Gera 2.1 og 2.2
/home/jeedo/Calendar/xc10Oct2003:() Stærðfræði: gera 1.4A 25-27
/home/jeedo/Calendar/xc13Oct2003:() Félagsfræði:
/home/jeedo/Calendar/xc13Oct2003:() Stærðfræði: Gera heima í1.4.A 28-30
/home/jeedo/Calendar/xc13Oct2003:() Stærðfræði: Gera 1.4B dæmi 11
/home/jeedo/Calendar/xc13Oct2003:() Stærðfræði: Lesa kafla 2.1B í bókinni
/home/jeedo/Calendar/xc20Oct2003:() Íslenska: vera búinn að velja einhverja bók til að lesa í íslensku sjá blöð í möppu
/home/jeedo/Calendar/xc2Oct2003:() Danska: Gera opgave 3,4,4A,5A
/home/jeedo/Calendar/xc2Oct2003:() Stærðfræði: Æfing 1.4A 1-18
/home/jeedo/Calendar/xc31Oct2003:() Danska: Vera búinn með gule handsker í dönsku
/home/jeedo/Calendar/xc31Oct2003:() Íslenska: Vera búinn með Hýbíli Vindanna
/home/jeedo/Calendar/xc3Oct2003:() Þýska: gera 1.sta kafla í vinnubók.
/home/jeedo/Calendar/xc3Oct2003:() Danska: Gera verkefni 5*
/home/jeedo/Calendar/xc6Oct2003:() Danska: OPgave 5BC
/home/jeedo/Calendar/xc6Oct2003:() Stærðfræði: 1.4A. 19-24
/home/jeedo/Calendar/xc6Oct2003:() Stærðfræði: 1.4B 1-8
/home/jeedo/Calendar/xc7Oct2003:() Danska: Opgave 6 bls.35
/home/jeedo/Calendar/xc7Oct2003:() Danska: Opgave 8. bls 34. verkefni upp úr bls 53-58

Eftir Fögum:
Alma: 0 / 1
Danska: 1 / 6
Félagsfræði: 1 / 1
Íslenska: 2 / 2
Íþróttir: 0 / 0
Lífsleikni: 0 / 0
Stærðfræði: 1 / 7
Þýska: 1 / 2

Total: 25
Script Length: 22 lines ; Comments: 17 lines


Edit: Any add-ons, bugfixes, better ways to approach the problem,whatever, are welcome:)
Back to top
View user's profile Send private message
BitJam
Advocate
Advocate


Joined: 12 Aug 2003
Posts: 2486
Location: Silver City, NM

PostPosted: Wed Oct 08, 2003 10:47 pm    Post subject: Reply with quote

I would use Perl to do this job. It will be much faster (but this is probably not a concern). The code would be much cleaner too. If you don't know Perl, that is a problem but this is a perfect project to use to start to learn how to use it.
Back to top
View user's profile Send private message
razamatan
Apprentice
Apprentice


Joined: 28 Feb 2003
Posts: 160

PostPosted: Fri Oct 10, 2003 2:48 am    Post subject: Reply with quote

BitJam wrote:
I would use Perl to do this job. It will be much faster (but this is probably not a concern). The code would be much cleaner too. If you don't know Perl, that is a problem but this is a perfect project to use to start to learn how to use it.


don't open the can of what scripting language is best... hell... even language...

you're inviting that kinda talk w/ this comment.
_________________
a razamatan doth speaketh,
"Never attribute to malice, that which can be adequately explained by stupidity"
Back to top
View user's profile Send private message
3lue9
n00b
n00b


Joined: 12 Oct 2003
Posts: 11

PostPosted: Wed Oct 15, 2003 3:18 am    Post subject: Reply with quote

yeah come on, we all know python is the best for this situation. I mean a todo list and tuples are like Peanut butter and jelly.
_________________
i don't have a signature
Back to top
View user's profile Send private message
snakattak3
Guru
Guru


Joined: 11 Dec 2002
Posts: 468
Location: Seattle

PostPosted: Wed Oct 15, 2003 6:57 am    Post subject: Reply with quote

Let me guess, you worked on this script instead of doing your homework :) It's ok, I'd do the same thing.
_________________
Ban Reality TV!
Adopt an Unanswered Post
Back to top
View user's profile Send private message
adammc
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 230
Location: Europe

PostPosted: Wed Oct 15, 2003 1:07 pm    Post subject: Reply with quote

I made a similar thing in perl, to run through apache...it's quite usefull for checking what I need to do when I'm not home. though, I found xpad to be far quicker ;)
_________________
There'd better be fudge when I get home...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum