Merge pull request #309 from dylanaraps/config_fixes

Config fixes
This commit is contained in:
Dylan Araps 2016-08-14 13:23:50 +10:00 committed by GitHub
commit 3f983245bb
1 changed files with 195 additions and 193 deletions

View File

@ -2512,7 +2512,7 @@ trim() {
# Error {{{
err() {
err+="$(color 1)[!]$(color fg) $1
err+="$(color 1)[!]\033[0m $1
"
}
@ -2598,17 +2598,6 @@ getuserconfig() {
err "Sourced user config ($config_file)"
}
# Check the commandline flags early for '--config none/off'
case "$@" in
*"--config off"* | *'--config "off"'* | *"--config 'off'"* | \
*"--config none"* | *'--config "none"'* | *"--config 'none'"* | *"--stdout"*)
config="off"
;;
esac
getdefaultconfig 2>/dev/null
[ "${config:-on}" == "on" ] && getuserconfig 2>/dev/null
# }}}
# Progress bars {{{
@ -2816,7 +2805,21 @@ exit 1
# Args {{{
while [ "$1" ]; do
getargs() {
# Check the commandline flags early for '--config none/off'
case "$@" in
*"--config off"* | *'--config "off"'* | *"--config 'off'"* | \
*"--config none"* | *'--config "none"'* | *"--config 'none'"* | *"--stdout"*)
config="off"
;;
*"--config --"*) ;;
*"--config"*) config="off" ;;
esac
[ "${config:-on}" == "on" ] && getuserconfig 2>/dev/null
while [ "$1" ]; do
case $1 in
# Info
--os_arch) os_arch="$2" ;;
@ -2965,11 +2968,11 @@ while [ "$1" ]; do
--test)
info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu cpu_usage gpu memory font disk battery song localip publicip users birthday term termfont)
readonly refresh_rate="on"
readonly shell_version="on"
readonly cpu_display="infobar"
readonly memory_display="infobar"
readonly disk_display="infobar"
refresh_rate="on"
shell_version="on"
cpu_display="infobar"
memory_display="infobar"
disk_display="infobar"
printinfo() {
if [ "$TRAVIS_OS_NAME" ]; then
@ -2986,10 +2989,6 @@ while [ "$1" ]; do
info linebreak
printf "%b%s" "\033[$(tput lines)H"
}
# Set the test func to readonly so a config source
# doesn't overwrite it.
readonly -f printinfo
;;
-v) verbose="on" ;;
@ -2999,13 +2998,16 @@ while [ "$1" ]; do
esac
shift
done
done
}
# }}}
# Call Functions and Finish Up {{{
main() {
getdefaultconfig 2>/dev/null
getargs "$@"
getos
# Restore cursor and clear screen on ctrl+c
@ -3058,12 +3060,12 @@ main() {
[ "$scrot" == "on" ] && takescrot
# Show error messages
[ "$verbose" == "on" ] && printf "%s" "$err"
[ "$verbose" == "on" ] && printf "%b%s" "$err"
# Reset exit status of the tests above
printf "%s"
}
main
main "$@"
# }}}