#!/bin/sh

# tuxpaint-savedir.sh
# 
# Use 'kdialog' to ask the user who they are, and then use that choice
# to determine what directory Tux Paint should save its files in
# (via the "--savedir" command-line option)
#
# Bill Kendrick
# bill@newbreedsoftware.com
# http://www.newbreedsoftware.com/tuxpaint/
#
# 2005.Feb.09 - 2005.Feb.09


# The file specified here should contain a list of directories and names,
# each on their own line, like so:
#
#   albert
#   Albert Calahan
#   kendrick
#   Bill Kendrick
#   someone_else
#   Someone else

USERS_FILE=userlist.txt


# Use the following variable to specify a base directory, where the ones
# listed in the 'USERS_FILE' are contained.  (So that you do not need to
# list it over and over again in the text file.)  For example:
# 
# BASE_SAVEIDR=/mnt/bigserver/classes/art/tuxpaint

BASE_SAVEDIR=~/tuxpaint-users

# -------- End of option variables ----------



# Call "kdialog" to show a list of names; store the result in "USERNAME"
# 
USERNAME=`kdialog --title "Tux Paint" --menu "Who are you?" \`sed -e s/\ /-/g $USERS_FILE\``


# Construct the full directory path by prepending the base directory
# 
SAVEDIR=$BASE_SAVEDIR/$USERNAME/


# Make sure the directory exists -- just in case!
# 
mkdir $SAVEDIR


# Run Tux Paint with the appropriate "--savedir" option;
# all other options sent to this shell script will be fed to Tux Paint
# as well (via the shell "$*" argument)
# 
tuxpaint --savedir $SAVEDIR $*

