You can now use ANY bash syntax when customizing what gets displayed, for example you could use an if statment to only show info when condition is true!
This commit is contained in:
parent
c5c34637b8
commit
9daacddda1
1 changed files with 94 additions and 109 deletions
203
fetch
203
fetch
|
@ -28,39 +28,47 @@ export LANGUAGE=C
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
# What to display and in what order.
|
# What to display and in what order.
|
||||||
|
# You can use ANY bash syntax in the function below!
|
||||||
|
# For example you could use if statments to only print info
|
||||||
|
# when a condition is true!
|
||||||
#
|
#
|
||||||
# Format is: "Subtitle: function name"
|
# The script comes with two helper functions:
|
||||||
# Additional lines you can use include:
|
# info:
|
||||||
# "underline" "linebreak" "echo: msg here" "title: title here"
|
# info "subtitle" funcname
|
||||||
|
# prin:
|
||||||
|
# prin "Custom message to print"
|
||||||
|
# prin "Subtitle: Custom message to print"
|
||||||
|
# prin "Subtitle: $(date)"
|
||||||
#
|
#
|
||||||
# You can also include your own custom lines by using:
|
# You can also just use printf / echo to add lines but you'll
|
||||||
# "echo: subtitlehere: $(custom cmd here)"
|
# need to prefix your msg with "${padding}", for example:
|
||||||
# "echo: Custom string to print"
|
# echo "${padding} My custom message here"
|
||||||
#
|
#
|
||||||
# Optional info lines that are disabled by default are:
|
# Info functions enabled by default are:
|
||||||
# "getresolution" "getsong" "getvisualstyle" "getgpu"
|
# "title" "distro" "kernel" "uptime" "packages"
|
||||||
|
# "shell" "resolution" "windowmanager" "gtktheme"
|
||||||
|
# "gtkicons" "cpu" "memory" "cols"
|
||||||
#
|
#
|
||||||
# Info lines enabled by default are:
|
# Info functions that are disabled by default are:
|
||||||
# "gettitle" "getdistro" "getkernel" "getuptime" "getpackages"
|
# "resolution" "song" "visualstyle" "gpu"
|
||||||
# "getshell" "getresolution" "getwindowmanager" "getgtktheme"
|
printinfo () {
|
||||||
# "getgtkicons" "getcpu" "getmemory" "getcols"
|
info title
|
||||||
info=(
|
info underline
|
||||||
"gettitle"
|
|
||||||
"underline"
|
info "OS" distro
|
||||||
"OS: getdistro"
|
info "Kernel" kernel
|
||||||
"Kernel: getkernel"
|
info "Uptime" uptime
|
||||||
"Uptime: getuptime"
|
info "Packages" packages
|
||||||
"Packages: getpackages"
|
info "Shell" shell
|
||||||
"Shell: getshell"
|
info "Window Manager" windowmanager
|
||||||
"Resolution: getresolution"
|
info "GTK Theme" gtktheme
|
||||||
"Window Manager: getwindowmanager"
|
info "Icons" gtkicons
|
||||||
"GTK Theme: getgtktheme"
|
info "CPU" cpu
|
||||||
"Icons: getgtkicons"
|
info "Memory" memory
|
||||||
"CPU: getcpu"
|
|
||||||
"Memory: getmemory"
|
info linebreak
|
||||||
"linebreak"
|
info cols
|
||||||
"getcols"
|
}
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Window Manager
|
# Window Manager
|
||||||
|
@ -688,6 +696,7 @@ getgpu () {
|
||||||
nvidia*)
|
nvidia*)
|
||||||
gpu=${gpu/'NVIDIA Corporation' }
|
gpu=${gpu/'NVIDIA Corporation' }
|
||||||
gpu=${gpu/'nVidia Corporation' }
|
gpu=${gpu/'nVidia Corporation' }
|
||||||
|
gpu=${gpu/G????M }
|
||||||
gpu=${gpu/G???? }
|
gpu=${gpu/G???? }
|
||||||
gpu=${gpu/'['}
|
gpu=${gpu/'['}
|
||||||
gpu=${gpu/']'}
|
gpu=${gpu/']'}
|
||||||
|
@ -1103,7 +1112,62 @@ takescrot () {
|
||||||
# Text Formatting {{{
|
# Text Formatting {{{
|
||||||
|
|
||||||
|
|
||||||
underline () {
|
info () {
|
||||||
|
# Call the function and update variable
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
get$1 2>/dev/null
|
||||||
|
eval output="\$${1}"
|
||||||
|
else
|
||||||
|
get$2 2>/dev/null
|
||||||
|
eval output="\$${2}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
title)
|
||||||
|
string="${bold}${title_color}${output}"
|
||||||
|
string="${string/@/${at_color}@${title_color}}"
|
||||||
|
length=${#output}
|
||||||
|
;;
|
||||||
|
|
||||||
|
underline)
|
||||||
|
string="${underline_color}${output}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
linebreak | cols)
|
||||||
|
string=""
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
string="${bold}${subtitle_color}${1}${clear}"
|
||||||
|
string+="${colon_color}: ${info_color}${output}"
|
||||||
|
length=$((${#subtitle} + ${#output} + 2))
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "%b%s\n" "${padding}${string}${clear}"
|
||||||
|
}
|
||||||
|
|
||||||
|
prin () {
|
||||||
|
case "$1" in
|
||||||
|
*:*)
|
||||||
|
subtitle=${1%%:*}
|
||||||
|
output=${1#*: }
|
||||||
|
|
||||||
|
string="${bold}${subtitle_color}${subtitle}${clear}"
|
||||||
|
string+="${colon_color}: ${info_color}${output}"
|
||||||
|
length=$((${#subtitle} + ${#output} + 1))
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
string="${info_color}${1}"
|
||||||
|
length=${#1}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "%b%s\n" "${padding}${string}${clear}"
|
||||||
|
}
|
||||||
|
|
||||||
|
getunderline () {
|
||||||
underline=$(printf %"$length"s)
|
underline=$(printf %"$length"s)
|
||||||
underline=${underline// /$underline_char}
|
underline=${underline// /$underline_char}
|
||||||
}
|
}
|
||||||
|
@ -1307,85 +1371,6 @@ done
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# Print Info {{{
|
|
||||||
|
|
||||||
|
|
||||||
printinfo () {
|
|
||||||
for info in "${info[@]}"; do
|
|
||||||
function=${info#*: }
|
|
||||||
subtitle=${info%:*}
|
|
||||||
|
|
||||||
case "$function" in
|
|
||||||
"get"*)
|
|
||||||
# Call the function
|
|
||||||
$function 2>/dev/null
|
|
||||||
|
|
||||||
# Update the variable
|
|
||||||
eval output="\$${function/get/}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$info" in
|
|
||||||
echo:*:*)
|
|
||||||
info=${function#*: }
|
|
||||||
subtitle=${function/:*/}
|
|
||||||
string="${bold}${subtitle_color}${subtitle}${clear}"
|
|
||||||
string+="${colon_color}: ${info_color}${info}"
|
|
||||||
length=${#function}
|
|
||||||
;;
|
|
||||||
|
|
||||||
echo:*)
|
|
||||||
string="${info_color}${function}"
|
|
||||||
length=${#function}
|
|
||||||
;;
|
|
||||||
|
|
||||||
title:*)
|
|
||||||
string="${bold}${title_color}${function}"
|
|
||||||
length=${#function}
|
|
||||||
;;
|
|
||||||
|
|
||||||
linebreak)
|
|
||||||
string=""
|
|
||||||
;;
|
|
||||||
|
|
||||||
underline)
|
|
||||||
if [ "$underline" == "on" ]; then
|
|
||||||
underline
|
|
||||||
string="${underline_color}${underline}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
"")
|
|
||||||
continue
|
|
||||||
;;
|
|
||||||
|
|
||||||
gettitle)
|
|
||||||
string="${bold}${title_color}${output}"
|
|
||||||
string="${string/@/${at_color}@${title_color}}"
|
|
||||||
length=${#output}
|
|
||||||
;;
|
|
||||||
|
|
||||||
*:*)
|
|
||||||
string="${bold}${subtitle_color}${subtitle}${clear}"
|
|
||||||
string+="${colon_color}: ${info_color}${output}"
|
|
||||||
length=$((${#subtitle} + ${#output} + 2))
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
string="$output"
|
|
||||||
length=${#output}
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
printf "%b%s\n" "${padding}${string}${clear}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
# Call Functions and Finish Up {{{
|
# Call Functions and Finish Up {{{
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue