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

View file

@ -2512,7 +2512,7 @@ trim() {
# Error {{{ # Error {{{
err() { err() {
err+="$(color 1)[!]$(color fg) $1 err+="$(color 1)[!]\033[0m $1
" "
} }
@ -2598,17 +2598,6 @@ getuserconfig() {
err "Sourced user config ($config_file)" 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 {{{ # Progress bars {{{
@ -2816,6 +2805,20 @@ exit 1
# Args {{{ # Args {{{
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 while [ "$1" ]; do
case $1 in case $1 in
# Info # Info
@ -2965,11 +2968,11 @@ while [ "$1" ]; do
--test) --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) 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" refresh_rate="on"
readonly shell_version="on" shell_version="on"
readonly cpu_display="infobar" cpu_display="infobar"
readonly memory_display="infobar" memory_display="infobar"
readonly disk_display="infobar" disk_display="infobar"
printinfo() { printinfo() {
if [ "$TRAVIS_OS_NAME" ]; then if [ "$TRAVIS_OS_NAME" ]; then
@ -2986,10 +2989,6 @@ while [ "$1" ]; do
info linebreak info linebreak
printf "%b%s" "\033[$(tput lines)H" 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" ;; -v) verbose="on" ;;
@ -3000,12 +2999,15 @@ while [ "$1" ]; do
shift shift
done done
}
# }}} # }}}
# Call Functions and Finish Up {{{ # Call Functions and Finish Up {{{
main() { main() {
getdefaultconfig 2>/dev/null
getargs "$@"
getos getos
# Restore cursor and clear screen on ctrl+c # Restore cursor and clear screen on ctrl+c
@ -3058,12 +3060,12 @@ main() {
[ "$scrot" == "on" ] && takescrot [ "$scrot" == "on" ] && takescrot
# Show error messages # Show error messages
[ "$verbose" == "on" ] && printf "%s" "$err" [ "$verbose" == "on" ] && printf "%b%s" "$err"
# Reset exit status of the tests above # Reset exit status of the tests above
printf "%s" printf "%s"
} }
main main "$@"
# }}} # }}}