Table of Contents
UzZas
~~META: status = active &relation firstimage = :project:uzzas:plostboros.svg ~~
UzZas is TUI based minimalistic reminder of recurring events.
Main purpose is to periodically urge the user to complete the tasks which have to be done periodically - like biweekly changing the water in home aquarium, monthly payout to local mafia Protectors of the Throne goverment and so on.
Usage
uzzas.sh ACTION
ACTION could be one of:
- (add|-a|–add) - Add new entry
- (list|-l|–list) - List all entries sorted by due date
- (delete|-d|–delete) - Delete entry
- (today|-t|–today) - Show entries which are planned for today
- (tomorrow|-T|–tomorrow) - Show entries which are planned for tomorrow
- (ack|-A|–ack) - Mark entry as done and activate next recurrence
- (install|-i|–install) - Install UzZas (create uzzas.db and CRON entry)
- (ping|-p|–ping) - Graphical equivalent of -t
- (help|-h|–help) - Help
- (edit|-e|–edit) - Edit entry
- (clone|-c|–clone|copy|–copy) - Clone (and modify) entry
Installation
- Check if the dependencies are met (bash interpreter, sqlite3). If you want automatic notifications, you need also CRON and zenity.
- Download the script and make it executable “chmod +x uzzas.sh”.
- Run “uzzas.sh -i” to create the database and to create crontab entry.
If you will ever update/modify the uzzas.sh script, do NOT reinstall it.
$ ./uzzas.sh -i ==== UzZas installed ==== See brmlab.cz/project/uzzas/start for more info
Adding events
Run “uzzas.sh -a” and complete few challenging questins, see example below:
$ ./uzzas.sh -a ==== Enter new task ==== First time planned to (yyyy-mm-dd): 2018-06-16 Repeat each (days): 7 Item...: Aquarium ...containing: Cutteries Action/note: Wipe ADD? (Y/n) y Added!
Listing events
To get list of events, sorted by due-date proximity (most urgent up), run “uzzas.sh -l”
$ ./uzzas.sh -l 2018-06-16 3 krabice 1 plostenka dugesia 2018-06-16 7 Aquarium Cutteries Wipe 2018-06-19 3 krabice 1. plostenka dugesia 2018-06-23 7 Plostenkoi Dugesie Vymen vodu
To see what have to be done today, run “uzzas.sh -t” for terminal, or “uzzas.sh -p” for graphical overview:
$ ./uzzas.sh -t 2018-06-16 3 krabice 1 plostenka dugesia 2018-06-16 7 Aquarium Cutteries Wipe
To see what have to be done tomorrow, run “uzzas.sh -T”. The output is similar to the today's listing.
Marking event as completed
If the event is completed, it is automatically postponed to the defined reoccurence date. To do so, run “uzzas.sh -A”. In the list are displayed only tasks planned for the current day.
$ ./uzzas.sh -A Select which task is done 1 krabice 1 plostenka dugesia 6 Aquarium Cutteries Wipe Done is: (0 = nothing; a = ALL) 0 Nothing done!
Deleting an event
If the reoccuring event is no longer valid, run “uzzas.sh -d”
$ ./uzzas.sh -d ==== Pick which action to delete (first column) ==== 1 2018-06-16 krabice 1 plostenka dugesia 3 2018-06-19 krabice 1. plostenka dugesia 5 2018-06-23 Plostenkoi Dugesie Vymen vodu 6 2018-06-16 Aquarium Cutteries Wipe Delete: (0 = cancel) 0 Not removed!
Editing event
To edit existing event, run “uzzas.sh -e”.
$ ./uzzas.sh -e ==== Edit entry ==== 1 krabice 1 plostenka dugesia 3 krabice 2 plastenka chcije 5 Plostenkoi Dugesie Vymen vodu 6 Aquarium Cutteries Wipe 7 Aqua2 Modry Wipe Edit: (0 = nothing) 7 First time planned to (yyyy-mm-dd): 2018-07-16 Repeat each (days): 7 Item...: Aqua2 ...containing: Modry Action/note: Wipe EDIT? (Y/n) Tasks edited!
Cloning entry
To clone/copy entry, possibly with modification, run “uzzas.sh -c”
$ ./uzzas.sh -c ==== Clone entry ==== 1 krabice 1 plostenka dugesia 3 krabice 2 plastenka chcije 5 Plostenkoi Dugesie Vymen vodu 6 Aquarium Cutteries Wipe 7 Aqua2 Modry Wipe Clone: (0 = nothing) 7 == Edit cloned entry == First time planned to (yyyy-mm-dd): 2018-08-16 Repeat each (days): 7 Item...: Aqua2 ...containing: Modry Action/note: Wipe COPY? (Y/n) Tasks copied!
Source code
Download the script and make it executable “chmod +x uzzas.sh”.
Run “uzzas.sh -i” to create the database and to create crontab entry for reminding you.
After update of the uzzas.sh script, do NOT reinstall it!
- uzzas.sh
#!/bin/bash # # UzZas - primitive boss behind your shoulder # # Dependency: CRON, sqlite3 # # Usage: # # uzzas.sh # dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" akce="$1" db="$dir/uzzas.db" case "$akce" in "add"|"-a"|"--add"|"new") echo "==== Enter new task ====" echo " First time planned to (yyyy-mm-dd):" read day echo " Repeat each (days):" read incr echo " Item...:" read box echo " ...containing:" read ins echo " Action/note:" read note echo "ADD? (Y/n)" read ack if [[ "$ack" != "n" ]]; then sqlite3 "$db" "INSERT INTO zas VALUES (date('$day'),$incr,'$box','$ins','$note');" echo "Added!" else echo "Adding cancelled!" fi ;; "list"|"-l"|"--list"|"show"|"--show") echo ".mode column^SELECT * FROM zas ORDER BY day ASC;" | tr '^' '\n' | sqlite3 "$db" ;; "delete"|"del"|"-d"|"--delete") echo "==== Pick which action to delete (first column) ====" echo ".mode column^SELECT rowid,day,box,inside,note FROM zas ORDER BY rowid ASC;" | tr '^' '\n' | sqlite3 "$db" echo " Delete: (0 = cancel)" read del if [[ "$del" > "0" ]]; then sqlite3 "$db" "DELETE FROM zas WHERE rowid='$del' LIMIT 1;" echo "Removed!" else echo "Not removed!" fi ;; "today"|"-t"|"--today") echo ".mode column^SELECT * FROM zas WHERE day=date('now');" | tr '^' '\n' | sqlite3 "$db" ;; "tomorrow"|"-T"|"--tomorrow") echo "==== Tomorrow TODO list ====" echo ".mode column^SELECT * FROM zas WHERE day=date('now','+1 day');" | tr '^' '\n' | sqlite3 "$db" ;; "ack"|"-A"|"--ack"|"done") echo "Select which task is done" echo ".mode column^SELECT rowid,box,inside,note FROM zas WHERE day=date('now') ORDER BY rowid ASC;" | tr '^' '\n' | sqlite3 "$db" echo " Done is: (0 = nothing; a = ALL)" read hot if [[ "$hot" == "a" ]]; then sqlite3 "$db" "UPDATE zas SET day=date(day,'+'||increment||' day');" echo "All today's tasks postponed!" else if [[ "$hot" =~ ^[0-9]+$ ]] 2> /dev/null then if [[ "$hot" > "0" ]]; then sqlite3 "$db" "UPDATE zas SET day=date(day,'+'||increment||' day') WHERE rowid=$hot LIMIT 1;" echo "Task postponed!" else echo "Nothing done!" fi else echo "Invalid value!" fi fi ;; "install"|"-i"|"--install") touch "$db" sqlite3 "$db" "CREATE TABLE IF NOT EXISTS zas (day TIMESTAMP,increment INTEGER,box TEXT,inside TEXT,note TEXT);" (crontab -l 2>/dev/null; echo "0 8-23 * * * DISPLAY=:0 $dir/uzzas.sh ping") | crontab - echo "==== UzZas installed ====" echo " See brmlab.cz/project/uzzas/start for more info" ;; "ping"|"-p"|"--ping") # Invoked via CRON, display graphical count=$(sqlite3 "$db" "SELECT count(rowid) FROM zas WHERE day=date('now');") if [[ "$count" > "0" ]]; then boxlen=$(sqlite3 "$db" "SELECT max(length(box)) FROM zas WHERE day=date('now');") inslen=$(sqlite3 "$db" "SELECT max(length(inside)) FROM zas WHERE day=date('now');") notelen=$(sqlite3 "$db" "SELECT max(length(note)) FROM zas WHERE day=date('now');") todo=$(echo ".headers on^.width $boxlen $inslen $notelen^.mode column^SELECT box,inside,note FROM zas WHERE day=date('now');" | tr '^' '\n' | sqlite3 "$db") #zenity --width=600 --info --text="$todo" --title="UzZas" zenity --info --title="UzZas" --no-wrap --text="<tt>$todo</tt>" fi ;; "help"|"-h"|"--help") echo "==== UzZas ====" echo " Minimalistic reminder of recurrent events" echo " " echo "==== Dependencies ====" echo " - BASH interpreter (b4ckd00r)" echo " - sqlite3 (for storing the events)" echo " - CRON (for recurring invocation)" echo " - zenity (for graphical reminder)" echo " " echo "==== Usage ====" echo " uzzas.sh ACTION" echo " " echo " ACTION could be one of:" echo " (add|-a|--add) - Add new entry" echo " (list|-l|--list) - List all entries sorted by due date" echo " (delete|-d|--delete) - Delete entry" echo " (today|-t|--today) - Show entries which are planned for today" echo " (tomorrow|-T|--tomorrow) - Show entries which are planned for tomorrow" echo " (ack|-A|--ack) - Mark entry as done and activate next recurrence" echo " (install|-i|--install) - Install UzZas (create uzzas.db and CRON entry)" echo " (ping|-p|--ping) - Graphical equivalent of -t" echo " (help|-h|--help) - This help" echo " (edit|-e|--edit) - Edit existing entry" echo " (clone|-c|--clone) - Clone (and modify) existing entry" echo " " echo "==== See brmlab.cz/project/uzzas/start for more info ====" echo " " ;; "edit"|"-e"|"--edit") echo "==== Edit entry ====" echo ".mode column^SELECT rowid,box,inside,note FROM zas ORDER BY rowid ASC;" | tr '^' '\n' | sqlite3 "$db" echo " Edit: (0 = nothing)" read edit if [[ "$edit" > "0" ]]; then row=$(echo ".mode line^SELECT * FROM zas WHERE rowid=$edit LIMIT 1;" | tr '^' '\n' | sqlite3 "$db") day=$(echo "$row" | grep -e "^[ ]*day = " | sed -e 's/[ ]*day = //g') incr=$(echo "$row" | grep -e "^[ ]*increment = " | sed -e 's/[ ]*increment = //g') box=$(echo "$row" | grep -e "^[ ]*box = " | sed -e 's/[ ]*box = //g') ins=$(echo "$row" | grep -e "^[ ]*inside = " | sed -e 's/[ ]*inside = //g') note=$(echo "$row" | grep -e "^[ ]*note = " | sed -e 's/[ ]*note = //g') echo " First time planned to (yyyy-mm-dd):" read -e -i "$day" day echo " Repeat each (days):" read -e -i "$incr" incr echo " Item...:" read -e -i "$box" box echo " ...containing:" read -e -i "$ins" ins echo " Action/note:" read -e -i "$note" note echo "EDIT? (Y/n)" read ack if [[ "$ack" != "n" ]]; then sqlite3 "$db" "UPDATE zas SET day='$day',box='$box',increment='$incr',inside='$ins',note='$note' WHERE rowid=$edit LIMIT 1;" echo "Tasks edited!" else echo "Edit cancelled!" fi else echo "Invalid value!" fi ;; "clone"|"-c"|"--clone"|"copy"|"--copy") echo "==== Clone entry ====" echo ".mode column^SELECT rowid,box,inside,note FROM zas ORDER BY rowid ASC;" | tr '^' '\n' | sqlite3 "$db" echo " Clone: (0 = nothing)" read clone if [[ "$clone" > "0" ]]; then row=$(echo ".mode line^SELECT * FROM zas WHERE rowid=$clone LIMIT 1;" | tr '^' '\n' | sqlite3 "$db") day=$(echo "$row" | grep -e "^[ ]*day = " | sed -e 's/[ ]*day = //g') incr=$(echo "$row" | grep -e "^[ ]*increment = " | sed -e 's/[ ]*increment = //g') box=$(echo "$row" | grep -e "^[ ]*box = " | sed -e 's/[ ]*box = //g') ins=$(echo "$row" | grep -e "^[ ]*inside = " | sed -e 's/[ ]*inside = //g') note=$(echo "$row" | grep -e "^[ ]*note = " | sed -e 's/[ ]*note = //g') echo "== Edit cloned entry ==" echo " First time planned to (yyyy-mm-dd):" read -e -i "$day" day echo " Repeat each (days):" read -e -i "$incr" incr echo " Item...:" read -e -i "$box" box echo " ...containing:" read -e -i "$ins" ins echo " Action/note:" read -e -i "$note" note echo "COPY? (Y/n)" read ack if [[ "$ack" != "n" ]]; then sqlite3 "$db" "INSERT INTO zas VALUES (date('$day'),$incr,'$box','$ins','$note');" echo "Tasks copied!" else echo "Copy cancelled!" fi else echo "Invalid value!" fi ;; esac exit