User Tools

Site Tools


project:uzzas:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
project:uzzas:start [2018/06/16 20:14] sachyproject:uzzas:start [2018/06/17 20:53] sachy
Line 3: Line 3:
 {{template>:project:infobox| {{template>:project:infobox|
 name=UzZas| name=UzZas|
-image= |+image=.:uzzas:plostboros.svg?400 |
 founder=[[user:sachy:start]]| founder=[[user:sachy:start]]|
 interested=[[user:sumie-dh]]| interested=[[user:sumie-dh]]|
Line 11: Line 11:
 ~~META: ~~META:
 status = active status = active
-&relation firstimage = +&relation firstimage = project:uzzas:plostboros.svg
 ~~ ~~
  
Line 30: Line 30:
   * **(install|-i|--install)** - Install UzZas (create uzzas.db and CRON entry)   * **(install|-i|--install)** - Install UzZas (create uzzas.db and CRON entry)
   * **(ping|-p|--ping)** - Graphical equivalent of -t   * **(ping|-p|--ping)** - Graphical equivalent of -t
-  * **(help|-h|--help)** - help+  * **(help|-h|--help)** - Help 
 +  * **(edit|-e|--edit)** - Edit entry 
 +  * **(clone|-c|--clone|copy|--copy)** - Clone (and modify) entry
  
 ==== Installation ==== ==== Installation ====
  
   - Check if the dependencies are met (bash interpreter, sqlite3). If you want automatic notifications, you need also CRON and zenity.   - Check if the dependencies are met (bash interpreter, sqlite3). If you want automatic notifications, you need also CRON and zenity.
-  - Run "uzzas.sh -i"+  - 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.
  
 <code> <code>
Line 115: Line 120:
 0 0
 Not removed! Not removed!
 +</code>
 +
 +==== Editing event ====
 +
 +To edit existing event, run "uzzas.sh -e".
 +
 +<code>
 +$ ./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!
 +</code>
 +
 +==== Cloning entry ====
 +
 +To clone/copy entry, possibly with modification, run "uzzas.sh -c"
 +
 +<code>
 +$ ./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!
 </code> </code>
  
 ===== Source code ==== ===== 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!
  
 <code bash uzzas.sh> <code bash uzzas.sh>
Line 128: Line 198:
 # Usage: # Usage:
 # #
-#  zazas.sh+#  uzzas.sh
 # #
  
Line 134: Line 204:
 akce="$1" akce="$1"
 db="$dir/uzzas.db" db="$dir/uzzas.db"
- 
-# CREATE TABLE IF NOT EXISTS zas (day TIMESTAMP,increment INTEGER,box TEXT,inside TEXT,note TEXT); 
  
 case "$akce" in case "$akce" in
Line 212: Line 280:
     ;;     ;;
   "ping"|"-p"|"--ping") # Invoked via CRON, display graphical   "ping"|"-p"|"--ping") # Invoked via CRON, display graphical
-    todo=$(echo ".headers on^.width 20 20 40^.mode column^SELECT box,inside,note FROM zas WHERE day=date('now');" | tr '^' '\n' | sqlite3 "$db"+    count=$(sqlite3 "$db" "SELECT count(rowid) FROM zas WHERE day=date('now');"
-    zenity --width=600 --info --text="$todo" --title="UzZas"+    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")   "help"|"-h"|"--help")
Line 228: Line 303:
     echo "  uzzas.sh ACTION"     echo "  uzzas.sh ACTION"
     echo " "     echo " "
-    echo "  ACTION could one of:"+    echo "  ACTION could be one of:"
     echo "  (add|-a|--add) - Add new entry"     echo "  (add|-a|--add) - Add new entry"
     echo "  (list|-l|--list) - List all entries sorted by due date"     echo "  (list|-l|--list) - List all entries sorted by due date"
Line 238: Line 313:
     echo "  (ping|-p|--ping) - Graphical equivalent of -t"     echo "  (ping|-p|--ping) - Graphical equivalent of -t"
     echo "  (help|-h|--help) - This help"     echo "  (help|-h|--help) - This help"
 +    echo "  (edit|-e|--edit) - Edit existing entry"
 +    echo "  (clone|-c|--clone) - Clone (and modify) existing entry"
     echo " "     echo " "
     echo "==== See brmlab.cz/project/uzzas/start for more info ===="     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 esac
project/uzzas/start.txt · Last modified: 2018/06/17 20:53 by sachy