User Tools

Site Tools


project:uzzas:start

This is an old revision of the document!


UzZas

UzZas
project
founder: sachy
depends on:
interested: sumie-dh
software license: CC
hardware license: N/A

~~META: status = active &relation firstimage = ~~

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

Installation

  1. Check if the dependencies are met (bash interpreter, sqlite3). If you want automatic notifications, you need also CRON and zenity.
  2. Run “uzzas.sh -i”
$ ./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!

Source code

uzzas.sh
#!/bin/bash
#
# UzZas - primitive boss behind your shoulder
#
# Dependency: CRON, sqlite3
#
# Usage:
#
#  zazas.sh
#
 
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
akce="$1"
db="$dir/uzzas.db"
 
# CREATE TABLE IF NOT EXISTS zas (day TIMESTAMP,increment INTEGER,box TEXT,inside TEXT,note TEXT);
 
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
		todo=$(echo ".headers on^.width 20 20 40^.mode column^SELECT box,inside,note FROM zas WHERE day=date('now');" | tr '^' '\n' | sqlite3 "$db")
		zenity --width=600 --info --text="$todo" --title="UzZas"
		;;
	"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 b 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 " "
		echo "==== See brmlab.cz/project/uzzas/start for more info ===="
		;;
esac
 
exit
project/uzzas/start.1529179873.txt.gz · Last modified: 2018/06/16 20:11 by sachy