Merge pull request #156 from dylanaraps/stdout_fix

Fix stdout mode when used with the cpu function.
This commit is contained in:
Dylan Araps 2016-03-17 16:44:17 +11:00
commit 098a962b59

View file

@ -959,8 +959,9 @@ getcpu () {
"bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; "bar") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;;
"infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;; "infobar") prin "${subtitle} Usage: ${cpu_usage} $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} )))" ;;
"barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;; "barinfo") prin "${subtitle} Usage: $(bar "${cpu_usage/'%'}" $(( 100 * ${cores} ))) ${cpu_usage}" ;;
"off") ;;
esac esac
unset cpu [ "$stdout_mode" != "on" ] && unset cpu
} }
# }}} # }}}
@ -1246,7 +1247,7 @@ getsong () {
esac esac
# Display Artist and Title on seperate lines. # Display Artist and Title on seperate lines.
if [ "$song_shorthand" == "on" ]; then if [ "$song_shorthand" == "on" ] && [ "$stdout_mode" != "on" ]; then
artist="${song/ -*}" artist="${song/ -*}"
song=${song/$artist - } song=${song/$artist - }
@ -1555,7 +1556,7 @@ getbattery () {
title="$subtitle" title="$subtitle"
# If shorthand is on, print each value on the same line # If shorthand is on, print each value on the same line
if [ "$battery_shorthand" == "on" ]; then if [ "$battery_shorthand" == "on" ] || [ "$stdout_mode" == "on" ]; then
battery=${batteries[*]} battery=${batteries[*]}
battery=${battery// /%, } battery=${battery// /%, }
battery="${battery}%" battery="${battery}%"
@ -2725,11 +2726,12 @@ while [ "$1" ]; do
# Stdout # Stdout
--stdout) --stdout)
unset info_color colors unset info_color colors cpu_display bar prin
unset -f bar stdout_mode="on"
config="off"
case "$2" in case "$2" in
"--"* | "") printf "%s\n" "--stdout requires at least one argument"; exit ;; "--"* | "") printf "%s\n" "--stdout requires at least one argument"; exit ;;
*) shift; args=("$@"); config="off"; stdout ;; *) shift; args=("$@"); stdout ;;
esac esac
;; ;;