v0.8.4 added XDG path check and graph negative value fix

pull/19/head
aristocratos 2020-04-23 21:10:53 +02:00
parent dac039e595
commit 1c40f2e770
1 changed files with 6 additions and 5 deletions

11
bashtop
View File

@ -41,7 +41,7 @@ banner=(
"██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ " "██╔══██╗██╔══██║╚════██║██╔══██║ ██║ ██║ ██║██╔═══╝ "
"██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ " "██████╔╝██║ ██║███████║██║ ██║ ██║ ╚██████╔╝██║ "
"╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ") "╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ")
declare version="0.8.3" declare version="0.8.4"
declare banner_width=${#banner[0]} declare banner_width=${#banner[0]}
banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414") banner_colors=("#E62525" "#CD2121" "#B31D1D" "#9A1919" "#801414")
@ -983,7 +983,7 @@ create_graph() { #? Create a graph from an array of percentage values, usage;
graph_array[height]="" graph_array[height]=""
if [[ -z $no_guide ]]; then if [[ -z $no_guide ]]; then
print -v graph_array[$height] -m $((line+g_index[(-1)])) ${col} -jr 3 -fg ee -b -t "${side_num[1]}" -rs -fg $[${theme[main_fg]}] -t "${g_char[1]}" -rp ${width} -t "${g_char[2]}" print -v graph_array[$height] -m $((line+g_index[(-1)])) ${col} -jr 3 -fg ee -b -t "${side_num[1]}" -rs -fg ${theme[main_fg]} -t "${g_char[1]}" -rp ${width} -t "${g_char[2]}"
fi fi
#* If no color array was given, create a simple greyscale array #* If no color array was given, create a simple greyscale array
@ -1166,6 +1166,7 @@ create_mini_graph() { #? Create a one line high graph from an array of percenta
while ((x<value_width)); do while ((x<value_width)); do
#* Round current input_array value divided by 10 to closest whole number #* Round current input_array value divided by 10 to closest whole number
org_value=${input_array[offset+x]} org_value=${input_array[offset+x]}
if ((org_value<0)); then org_value=0; fi
if ((org_value==100)); then cur_value=10 if ((org_value==100)); then cur_value=10
elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -ge 5 ]]; then cur_value=$((${org_value::1}+1)) elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -ge 5 ]]; then cur_value=$((${org_value::1}+1))
elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -lt 5 ]]; then cur_value=$((${org_value::1})) elif [[ ${#org_value} -gt 1 && ${org_value:(-1)} -lt 5 ]]; then cur_value=$((${org_value::1}))
@ -3409,13 +3410,13 @@ main_loop() { #? main loop...
#? Pre main loop #? Pre main loop
#* Read config file or create if non existant #* Read config file or create if non existant
if [[ -d "$HOME/.config/bashtop" && -w "$HOME/.config/bashtop" ]] || mkdir -p "$HOME/.config/bashtop"; then config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/bashtop"
config_dir="$HOME/.config/bashtop" if [[ -d "${config_dir}" && -w "${config_dir}" ]] || mkdir -p "${config_dir}"; then
theme_dir="${config_dir}/themes" theme_dir="${config_dir}/themes"
if [[ ! -d "${theme_dir}" ]]; then mkdir -p "${theme_dir}"; fi if [[ ! -d "${theme_dir}" ]]; then mkdir -p "${theme_dir}"; fi
config_file="${config_dir}/bashtop.cfg" config_file="${config_dir}/bashtop.cfg"
# shellcheck source=/dev/null # shellcheck source=/dev/null
if [[ -e $config_file ]]; then if [[ -e "$config_file" ]]; then
source "$config_file" source "$config_file"
#* If current config is from an older version recreate config file and save user changes #* If current config is from an older version recreate config file and save user changes