Merge pull request #88 from dylanaraps/stdout
Cleanup 'stdout' functions
This commit is contained in:
commit
6f115b3c19
3
1.3.md
3
1.3.md
|
@ -16,3 +16,6 @@ is now calculated by fetch.
|
||||||
|
|
||||||
**Song**<br \>
|
**Song**<br \>
|
||||||
- Added `song_shorthand` which prints the Artist/Title on seperate lines.
|
- Added `song_shorthand` which prints the Artist/Title on seperate lines.
|
||||||
|
|
||||||
|
**Theme**<br\>
|
||||||
|
- Windows Visual Style is now a part of `getstyle`.
|
||||||
|
|
|
@ -342,20 +342,4 @@ config="on"
|
||||||
config_file="$HOME/.config/fetch/config"
|
config_file="$HOME/.config/fetch/config"
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Other Options {{{
|
|
||||||
|
|
||||||
# Separator to use in stdout mode.
|
|
||||||
# --stdout_separator string
|
|
||||||
stdout_separator=" "
|
|
||||||
|
|
||||||
# Hide/Show the title in stdout mode.
|
|
||||||
# --stdout_title on/off
|
|
||||||
stdout_title="off"
|
|
||||||
|
|
||||||
# Hide/Show each info's subtitle in stdout mode.
|
|
||||||
# --stdout_subtitles on/off
|
|
||||||
stdout_subtitles="on"
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
88
fetch
88
fetch
|
@ -360,22 +360,6 @@ config="on"
|
||||||
config_file="$HOME/.config/fetch/config"
|
config_file="$HOME/.config/fetch/config"
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# Other Options {{{
|
|
||||||
|
|
||||||
# Separator to use in stdout mode.
|
|
||||||
# --stdout_separator string
|
|
||||||
stdout_separator=" "
|
|
||||||
|
|
||||||
# Hide/Show the title in stdout mode.
|
|
||||||
# --stdout_title on/off
|
|
||||||
stdout_title="off"
|
|
||||||
|
|
||||||
# Hide/Show each info's subtitle in stdout mode.
|
|
||||||
# --stdout_subtitles on/off
|
|
||||||
stdout_subtitles="on"
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2053,11 +2037,6 @@ info () {
|
||||||
string="${bold}${title_color}${output}"
|
string="${bold}${title_color}${output}"
|
||||||
string="${string/@/${at_color}@${title_color}}"
|
string="${string/@/${at_color}@${title_color}}"
|
||||||
length=${#output}
|
length=${#output}
|
||||||
|
|
||||||
# Hide the title in stdout mode
|
|
||||||
[ "$stdout" == "on" ] && \
|
|
||||||
[ "$stdout_title" == "off" ] &&\
|
|
||||||
string=""
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
underline)
|
underline)
|
||||||
|
@ -2075,22 +2054,7 @@ info () {
|
||||||
[ -z "$2" ] && string=${string/*: }
|
[ -z "$2" ] && string=${string/*: }
|
||||||
|
|
||||||
# Print the string
|
# Print the string
|
||||||
if [ "$stdout" == "on" ]; then
|
printf "%b%s\n" "${padding}${string}${clear}"
|
||||||
|
|
||||||
# Unset the vars containg escape codes as lemonbar doesn't
|
|
||||||
# support them.
|
|
||||||
unset -v bold subtitle_color clear colon_color info_color \
|
|
||||||
underline_color title_color at_color
|
|
||||||
|
|
||||||
# Show/Hide subtitles
|
|
||||||
[ "$stdout_subtitles" == "off" ] && string=${string/*: }
|
|
||||||
|
|
||||||
# If the string isn't empty, print it.
|
|
||||||
[ ! -z "$string" ] && printf "%s" "${string}${stdout_separator}"
|
|
||||||
|
|
||||||
else
|
|
||||||
printf "%b%s\n" "${padding}${string}${clear}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -2115,11 +2079,7 @@ prin () {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Print the info
|
# Print the info
|
||||||
if [ "$stdout" == "on" ]; then
|
printf "%b%s\n" "${padding}${string}${clear}"
|
||||||
printf "%s" "${string}${stdout_separator}"
|
|
||||||
else
|
|
||||||
printf "%b%s\n" "${padding}${string}${clear}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -2127,21 +2087,17 @@ prin () {
|
||||||
# Stdout {{{
|
# Stdout {{{
|
||||||
|
|
||||||
stdout () {
|
stdout () {
|
||||||
printinfo () {
|
for func in "${args[@]}"; do
|
||||||
index=1
|
case "$func" in
|
||||||
for func in "${args[@]}"; do
|
"--"*) break ;;
|
||||||
|
*)
|
||||||
case "$func" in
|
"get$func" 2>/dev/null
|
||||||
"--stdout") continue ;;
|
eval output="\$$func"
|
||||||
"--"*) break ;;
|
printf "$output "
|
||||||
*)
|
;;
|
||||||
case "${args[$((index + 1))]}" in "--"*) unset stdout_separator ;; esac
|
esac
|
||||||
info "$func"
|
done
|
||||||
;;
|
exit
|
||||||
esac
|
|
||||||
index=$((index + 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -2366,9 +2322,6 @@ usage () { cat << EOF
|
||||||
--stdout info info Launch fetch in stdout mode which prints the info
|
--stdout info info Launch fetch in stdout mode which prints the info
|
||||||
in a plain-text format that you can use with
|
in a plain-text format that you can use with
|
||||||
lemonbar etc.
|
lemonbar etc.
|
||||||
--stdout_title on/off Hide/Show the title in stdout mode.
|
|
||||||
--stdout_separator string String to use as a separator in stdout mode.
|
|
||||||
--stdout_subtitles on/off Hide/Show the subtitles in stdout mode.
|
|
||||||
|
|
||||||
|
|
||||||
Screenshot:
|
Screenshot:
|
||||||
|
@ -2490,19 +2443,12 @@ while [ "$1" ]; do
|
||||||
--scrot_cmd) scrot_cmd="$2" ;;
|
--scrot_cmd) scrot_cmd="$2" ;;
|
||||||
|
|
||||||
# Stdout
|
# Stdout
|
||||||
--stdout_title) stdout_title="$2" ;;
|
|
||||||
--stdout_separator) stdout_separator="$2" ;;
|
|
||||||
--stdout_subtitles) stdout_subtitles="$2" ;;
|
|
||||||
--stdout)
|
--stdout)
|
||||||
case "$2" in
|
|
||||||
"--"* | "") stdout="on" ;;
|
|
||||||
*) stdout="on"; args=("$@"); stdout ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unset info_color colors
|
unset info_color colors
|
||||||
underline="off"
|
case "$2" in
|
||||||
image="off"
|
"--"* | "") echo "--stdout requires at least one argument"; exit ;;
|
||||||
color_blocks="off"
|
*) shift; args=("$@"); stdout ;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
|
|
Reference in New Issue