#!/bin/sh
# Matt Manjos, 2006 - This script is GPL: http://www.gnu.org/copyleft/gpl.html
# A script to create a png of todo items and apply it to compiz/cube
# Version 0.3

# Configuration:
RUNPATH=~/cubetodo
EDITOR=/usr/bin/nano

# User edits datafile with editor

$EDITOR $RUNPATH/datafile

# Create svg of desired todo list, taking template.svg as a header

{
cat $RUNPATH/template.svg

# Initialize variables

LINES=`wc -l < $RUNPATH/datafile`
TIMES=0

while [ $TIMES -lt $LINES ]; do

# Line by line, take data from datafile and output it with the tags around it

echo '<tspan x="65"' 'y="'"$[TIMES*60+60]"'"' 'id="'"tspan$TIMES"'"'">"
echo "`cat $RUNPATH/datafile|head -n $[TIMES+1]|tail -n 1`"
((TIMES++))
echo "</tspan>"
done

# Close tags

echo "</text>"
echo "</g>"
echo "</svg>"
} > $RUNPATH/cubetodo.svg

echo "Working..."

/usr/bin/rsvg-convert -o $RUNPATH/cubetodo.png < $RUNPATH/cubetodo.svg

# Set cube image as nothing, and then as generated png to invoke an update
/usr/bin/gconftool-2 -s -t list --list-type string /apps/compiz/plugins/cube/screen0/options/images_top \[/nothing\]
sleep 1
/usr/bin/gconftool-2 -s -t list --list-type string /apps/compiz/plugins/cube/screen0/options/images_top \[$RUNPATH/cubetodo.png\]
