Merge pull request #1152 from dylanaraps/simple

Added new simple mode for script usage
This commit is contained in:
Dylan Araps 2019-01-07 19:46:20 +02:00 committed by GitHub
commit af6230f0ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 14 deletions

View File

@ -4047,18 +4047,9 @@ color() {
stdout() {
image_backend="off"
unset subtitle_color
unset colon_color
unset info_color
unset underline_color
unset bold
unset title_color
unset at_color
unset text_padding
unset zws
unset reset
unset color_blocks
unset get_line_break
unset subtitle_color colon_color info_color underline_color bold title_color at_color \
text_padding zws reset color_blocks get_line_break bar_color_elapsed bar_color_total \
c1 c2 c3 c4 c5 c6 c7 c8
}
err() {
@ -4256,7 +4247,7 @@ decode_url() {
# FINISH UP
usage() { printf "%s" "\
Usage: neofetch --option \"value\" --option \"value\"
Usage: neofetch func_name --option \"value\" --option \"value\"
Neofetch is a CLI system information tool written in BASH. Neofetch
displays information about your system next to an image, your OS logo,
@ -4267,6 +4258,23 @@ NOTE: Every launch flag has a config option.
Options:
INFO:
func_name Specify a function name (second part of info() from config) to
quickly display only that function's information.
Example: neofetch uptime --uptime_shorthand tiny
Example: neofetch uptime disk wm memory
This can be used in bars and scripts like so:
memory=\"\$(neofetch memory)\"; memory=\"\${memory##*: }\"
For multiple outputs at once (each line of info in an array):
IFS=\$'\\n' read -d \"\" -ra info < <(neofetch memory uptime wm)
info=(\"\${info[@]##*: }\")
--disable infoname Allows you to disable an info line from appearing
in the output. 'infoname' is the function name from the
'print_info()' function inside the config file.
@ -4713,6 +4721,19 @@ get_args() {
done
}
get_simple() {
while [[ "$1" ]]; do
[[ $(type -t "get_$1") == function ]] && {
get_distro
stdout
simple=1
info "$1" "$1"
}
shift
done
((simple)) && exit
}
get_distro_ascii() {
# This function gets the distro ascii art and colors.
#
@ -8710,6 +8731,7 @@ main() {
eval "$config"
get_args "$@"
get_simple "$@"
[[ "$verbose" != "on" ]] && exec 2>/dev/null
get_distro
get_bold

View File

@ -4,7 +4,7 @@
Neofetch \- A fast, highly customizable system info script
.SH SYNOPSIS
.B neofetch
\fI\,--option "value" --option "value"\/\fR
\fI\,func_name --option "value" --option "value"\/\fR
.SH DESCRIPTION
Neofetch is a CLI system information tool written in BASH. Neofetch
displays information about your system next to an image, your OS logo,
@ -14,6 +14,24 @@ NOTE: Every launch flag has a config option.
.SH OPTIONS
.SS "INFO:"
.TP
func_name
Specify a function name (second part of info() from config) to
quickly display only that function's information.
.IP
Example: neofetch uptime \fB\-\-uptime_shorthand\fR tiny
.IP
Example: neofetch uptime disk wm memory
.IP
This can be used in bars and scripts like so:
.IP
memory="$(neofetch memory)"; memory="${memory##*: }"
.IP
For multiple outputs at once (each line of info in an array):
.IP
IFS=$'\en' read \fB\-d\fR "" \fB\-ra\fR info < <(neofetch memory uptime wm)
.IP
info=("${info[@]##*: }")
.TP
\fB\-\-disable\fR infoname
Allows you to disable an info line from appearing
in the output. 'infoname' is the function name from the