mirror of
https://gitlab.com/mattia.basaglia/ASCII-Pony.git
synced 2024-11-25 05:17:59 +01:00
Read config files for systempony
This commit is contained in:
parent
b861708c01
commit
eaac3ee344
1 changed files with 38 additions and 4 deletions
42
systempony
42
systempony
|
@ -139,7 +139,33 @@ function select_info()
|
||||||
INFO=($(echo "${*}" | column -t -s:,))
|
INFO=($(echo "${*}" | column -t -s:,))
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO read global and user config file
|
SELFDIR=$(dirname $(readlink -se "${BASH_SOURCE[0]}"))
|
||||||
|
function get_data_file()
|
||||||
|
{
|
||||||
|
if [ -e "$SELFDIR/$1" ]
|
||||||
|
then
|
||||||
|
# Not installed
|
||||||
|
echo "$SELFDIR/$1"
|
||||||
|
elif [ -e "$SELFDIR/../share/ascii-pony/$1" ]
|
||||||
|
then
|
||||||
|
# Installed with PREFIX=$SELFDIR/..
|
||||||
|
echo "$SELFDIR/../share/ascii-pony/$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read global config
|
||||||
|
globalconfig=$(get_data_file systempony.conf)
|
||||||
|
if [ -r "$globalconfig" ]
|
||||||
|
then
|
||||||
|
source "$globalconfig"
|
||||||
|
fi
|
||||||
|
# Read user config
|
||||||
|
if [ -r ~/.systempony ]
|
||||||
|
then
|
||||||
|
source ~/.systempony
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read parameters
|
||||||
while [ "$1" ]
|
while [ "$1" ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -170,6 +196,7 @@ do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Evaluate info
|
||||||
infoval=()
|
infoval=()
|
||||||
let maxkeyl=0
|
let maxkeyl=0
|
||||||
let maxvall=0
|
let maxvall=0
|
||||||
|
@ -191,9 +218,7 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
SELFDIR=$(dirname $(readlink -se "${BASH_SOURCE[0]}"))
|
ponydir=$(get_data_file "rendered/ansi/")
|
||||||
ponydir="$SELFDIR/rendered/ansi/"
|
|
||||||
[ ! -d "$ponydir" ] && ponydir="$SELFDIR/../share/ascii-pony/rendered/ansi/"
|
|
||||||
ponyfile="$ponydir/$PONY.colored.txt"
|
ponyfile="$ponydir/$PONY.colored.txt"
|
||||||
|
|
||||||
# WARNING most of the variable names below this point are pretty bad and should be refactored
|
# WARNING most of the variable names below this point are pretty bad and should be refactored
|
||||||
|
@ -271,5 +296,14 @@ then
|
||||||
fi
|
fi
|
||||||
let l++
|
let l++
|
||||||
done < "$ponyfile"
|
done < "$ponyfile"
|
||||||
|
else
|
||||||
|
let info_index=0
|
||||||
|
while [ $info_index -lt ${#INFO[@]} ]
|
||||||
|
do
|
||||||
|
printf "\x1b[31;1m%-${maxkeyl}s\x1b[0m: %s\n" \
|
||||||
|
"${INFO[$info_index]}" \
|
||||||
|
"${infoval[$info_index]}"
|
||||||
|
let info_index++
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue