From cb021c46ddb6616c33fa874a553f555893c8a22b Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Jun 2010 20:20:16 -0300 Subject: Adding system of preferences --- lib/keyringer/functions | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib') diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 19d677f..af84212 100644 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -3,6 +3,34 @@ # Common functions. # +# Setup main configuration and load preferences +function keyringer_config_load { + if [ -f "$HOME/.$NAME" ]; then + echo "Converting legacy configuration scheme..." + mv $HOME/.$NAME $HOME/.$NAME.tmp + mkdir $HOME/.$NAME + mv $HOME/.$NAME.tmp $CONFIG + fi + + if [ ! -e "$CONFIG" ]; then + echo "Creating $CONFIG..." + mkdir `dirname $CONFIG` + touch $CONFIG + chmod 600 $CONFIG + echo "# Keyringer config file." > $CONFIG + echo "" >> $CONFIG + fi + + keyringer_config_load_preferences +} + +function keyringer_config_load_preferences { + # Load custom keyring preferences + if [ ! -z "$PREFERENCES" ] && [ -e "$PREFERENCES" ]; then + source $PREFERENCES + fi +} + # Load a parameter from config function keyringer_config { if [ -z "$CONFIG" ]; then -- cgit v1.2.3