@@ -324,7 +324,7 @@ color_init_() { #? Check for theme file and set colors
324
324
done
325
325
326
326
# * Set background color if set, otherwise use terminal default
327
- if [[ -n ${theme[main_bg]} ]]; then theme[main_bg]=" ;48;2;${theme[main_bg]// / ;} " ; fi
327
+ if [[ -n ${theme[main_bg]} ]]; then theme[main_bg_dec]= " ${theme[main_bg]} " ; theme[ main_bg]=" ;48;2;${theme[main_bg]// / ;} " ; fi
328
328
329
329
# * Set colors from theme file if found, otherwise use default values
330
330
theme[main_fg]=" ${theme[main_fg]:- $main_fg } "
@@ -973,16 +973,16 @@ create_graph() { #? Create a graph from an array of percentage values, usage;
973
973
974
974
# * Set up graph array print side numbers and lines
975
975
print -v graph_array[0] -rs
976
- print -v graph_array[0] -m $(( line+ g_index[0 ])) ${col} ${normal_vals: +-jr 3 -fg ee -b -t " ${side_num[0]} " -rs -fg 90 -t " ${g_char[0]} " } -fg ${colors[100]}
976
+ print -v graph_array[0] -m $(( line+ g_index[0 ])) ${col} ${normal_vals: +-jr 3 -fg ee -b -t " ${side_num[0]} " -rs -fg ${theme[main_fg]} -t " ${g_char[0]} " } -fg ${colors[100]}
977
977
for(( i= 1 ;i< height;i++ )) ; do
978
- print -v graph_array[i] -m $(( line+ g_index[i])) ${col} ${normal_vals: +-r 3 -fg 90 -t " ${g_char[0]} " } -fg ${colors[$((100-i*100/height))]}
978
+ print -v graph_array[i] -m $(( line+ g_index[i])) ${col} ${normal_vals: +-r 3 -fg ${theme[main_fg]} -t " ${g_char[0]} " } -fg ${colors[$((100-i*100/height))]}
979
979
done
980
980
981
981
if [[ -z $no_guide ]]; then width=$(( width- 5 )) ; fi
982
982
983
983
graph_array[height]=" "
984
984
if [[ -z $no_guide ]]; then
985
- print -v graph_array[$height ] -m $(( line+ g_index[(- 1 )])) ${col} -jr 3 -fg ee -b -t " ${side_num[1]} " -rs -fg 90 -t " ${g_char[1]} " -rp ${width} -t " ${g_char[2]} "
985
+ 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]} "
986
986
fi
987
987
988
988
# * If no color array was given, create a simple greyscale array
@@ -1948,11 +1948,11 @@ draw_cpu() { #? Draw cpu and core graphs and print percentages
1948
1948
if (( resized> 0 )) ; then
1949
1949
local graph_a_size graph_b_size
1950
1950
graph_a_size=$(( height/ 2 )) ; graph_b_size=${graph_a_size}
1951
+
1951
1952
if (( graph_a_size* 2 < height)) ; then (( graph_a_size++ )) ; fi
1952
- # create_graph -o cpu_graph_a -d ${line} ${col} ${height} $((width-p_width-2)) -c color_cpu_graph cpu_history
1953
1953
create_graph -o cpu_graph_a -d ${line} ${col} ${graph_a_size} $(( width- p_width- 2 )) -c color_cpu_graph -n cpu_history
1954
1954
create_graph -o cpu_graph_b -d $(( line+ graph_a_size)) ${col} ${graph_b_size} $(( width- p_width- 2 )) -c color_cpu_graph -i -n cpu_history
1955
- # threads=${box[testing]} #! For testing, remove <--------------
1955
+
1956
1956
for(( i= 1 ;i<= threads;i++ )) ; do
1957
1957
create_mini_graph -o " cpu_core_graph_$i " -w 10 -c color_cpu_graph " cpu_core_history_$i "
1958
1958
done
@@ -2017,17 +2017,17 @@ draw_cpu() { #? Draw cpu and core graphs and print percentages
2017
2017
elif (( p_width> 24 + temp_width & i>= p_height- 2 )) ; then pt_line=$(( p_line+ i- y* 2 )) ; pt_col=$(( p_col+ 24 + temp_width))
2018
2018
else y=$i ; fi
2019
2019
2020
- print -v cpu_out_var -m $(( pt_line+ y)) $pt_col -rs -fg $p_normal_color -jl 7 -t " $name " -fg 30 " ⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀" -l 10 -t " $meter " \
2020
+ print -v cpu_out_var -m $(( pt_line+ y)) $pt_col -rs -fg $p_normal_color -jl 7 -t " $name " -fg ${theme[inactive_fg]} " ⡀⡀⡀⡀⡀⡀⡀⡀⡀⡀" -l 10 -t " $meter " \
2021
2021
-fg $cpu_p_color -jr 4 -t " ${cpu_usage[i]} " -fg $p_normal_color -t " %"
2022
2022
if [[ $check_temp == true ]]; then
2023
- print -v cpu_out_var -fg 30 " ⡀⡀⡀⡀⡀" -l 7 -t " ${! temp_name} " -fg $temp_color -jr 4 -t ${cpu[temp_${i}]} -fg $p_normal_color -t ${cpu[temp_unit]}
2023
+ print -v cpu_out_var -fg ${theme[inactive_fg]} " ⡀⡀⡀⡀⡀" -l 7 -t " ${! temp_name} " -fg $temp_color -jr 4 -t ${cpu[temp_${i}]} -fg $p_normal_color -t ${cpu[temp_unit]}
2024
2024
fi
2025
2025
2026
2026
if (( i> (p_height- 2 )* ( p_width/ (24 + temp_width) )- ( p_width/ (24 + temp_width) )- 1 )) ; then break ; fi
2027
2027
done
2028
2028
2029
2029
# * Print current CPU frequency right of the title in the meter box
2030
- print -v cpu_out_var -m $(( p_line- 1 )) $(( p_col+ p_width- 5 - ${# cpu[freq_string]} )) -fg 30 -t " ┤" -fg ${theme[title]} -b -t " ${cpu[freq_string]} " -rs -fg 30 -t " ├"
2030
+ print -v cpu_out_var -m $(( p_line- 1 )) $(( p_col+ p_width- 5 - ${# cpu[freq_string]} )) -fg ${theme[div_line]} -t " ┤" -fg ${theme[title]} -b -t " ${cpu[freq_string]} " -rs -fg ${theme[div_line]} -t " ├"
2031
2031
2032
2032
# * Print created text, graph and meters to output variable
2033
2033
draw_out+=" ${cpu_graph_a[*]}${cpu_graph_b[*]}${cpu_out_var} "
@@ -2150,9 +2150,9 @@ draw_mem() { #? Draw mem, swap and disk statistics
2150
2150
draw_processes () { # ? Draw processes and values to screen
2151
2151
local argument=" $1 "
2152
2152
if [[ -n $skip_process_draw && $argument != " now" ]]; then return ; fi
2153
- local line=${box[processes_line]} col=${box[processes_col]} width=${box[processes_width]} height=${box[processes_height]} out_line y=1 fg_step_r fg_step_g fg_step_b checker=2 page_string
2153
+ local line=${box[processes_line]} col=${box[processes_col]} width=${box[processes_width]} height=${box[processes_height]} out_line y=1 fg_step_r=0 fg_step_g=0 fg_step_b=0 checker=2 page_string
2154
2154
local reverse_string reverse_pos order_left=" ───────────┤" filter_string current_num detail_location det_no_add com_fg pg_arrow_up_fg pg_arrow_down_fg
2155
- local pid=0 pid_graph pid_step_r pid_step_g pid_step_b pid_add_r pid_add_g pid_add_b bg_add bg_step rgb_d=70 d_step proc_start up_fg down_fg page_up_fg page_down_fg this_box=processes
2155
+ local pid=0 pid_graph pid_step_r pid_step_g pid_step_b pid_add_r pid_add_g pid_add_b bg_add bg_step proc_start up_fg down_fg page_up_fg page_down_fg this_box=processes
2156
2156
local d_width=${box[details_width]} d_height=${box[details_height]} d_line=${box[details_line]} d_col=${box[details_col]}
2157
2157
local detail_graph_width=$(( d_width/ 3 + 2 )) detail_graph_height=$(( d_height- 1 )) kill_fg det_mod fg_add_r fg_add_g fg_add_b
2158
2158
local right_width=$(( d_width- detail_graph_width- 2 ))
@@ -2169,8 +2169,6 @@ draw_processes() { #? Draw processes and values to screen
2169
2169
pid_add_r=$(( (pid_r- (pid_r/ 6 ) )/ height))
2170
2170
pid_add_g=$(( (pid_g- (pid_g/ 6 ) )/ height))
2171
2171
pid_add_b=$(( (pid_b- (pid_b/ 6 ) )/ height))
2172
- # p_add=$((110/height))
2173
- d_add=$(( rgb_d/ height))
2174
2172
2175
2173
unset proc_out
2176
2174
@@ -2185,7 +2183,6 @@ draw_processes() { #? Draw processes and values to screen
2185
2183
2186
2184
if [[ ${# detail_history[@]} -eq 1 ]] || (( resized> 0 )) ; then
2187
2185
unset proc_det2
2188
- # detail_mem_graph ${#detail_history[@]} -lt 2
2189
2186
create_graph -o detail_graph -d $(( d_line+ 1 )) $(( d_col+ 1 )) ${detail_graph_height} ${detail_graph_width} -c color_cpu_graph -n detail_history
2190
2187
if (( tty_width> 120 )) ; then create_mini_graph -o detail_mem_graph -w $(( right_width/ 3 - 3 )) -nc detail_mem_history; fi
2191
2188
det_no_add=1
@@ -2268,7 +2265,7 @@ draw_processes() { #? Draw processes and values to screen
2268
2265
if (( det_columns>= 5 )) ; then print -v proc_out -jc $(( right_width/ det_columns- 1 )) -t " ${proc[detailed_threads]} " ; fi
2269
2266
2270
2267
print -v proc_out -m $(( d_line+ 4 )) ${right_col} -fg ${theme[title]} -b -jr $(( right_width/ 3 + 2 )) -t " Memory: ${proc[detailed_mem]} %" -t " "
2271
- if (( tty_width> 120 )) ; then print -v proc_out -rs -fg 30 -rp $(( right_width/ 3 - 3 )) " ⡀" -l $(( right_width/ 3 - 3 )) -fg ${theme[proc_misc]} -t " ${detail_mem_graph} " -t " " ; fi
2268
+ if (( tty_width> 120 )) ; then print -v proc_out -rs -fg ${theme[inactive_fg]} -rp $(( right_width/ 3 - 3 )) " ⡀" -l $(( right_width/ 3 - 3 )) -fg ${theme[proc_misc]} -t " ${detail_mem_graph} " -t " " ; fi
2272
2269
print -v proc_out -fg ${theme[title]} -b -t " ${proc[detailed_mem_string]} "
2273
2270
fi
2274
2271
@@ -2286,8 +2283,6 @@ draw_processes() { #? Draw processes and values to screen
2286
2283
pid_r=" $(( pid_r- ( pid_add_r* (proc[selected]- 1 ) ) )) "
2287
2284
pid_g=" $(( pid_g- ( pid_add_g* (proc[selected]- 1 ) ) )) "
2288
2285
pid_b=" $(( pid_b- ( pid_add_b* (proc[selected]- 1 ) ) )) "
2289
-
2290
- rgb_d=" $(( 70 - ( d_add* (proc[selected]- 1 ) ) )) "
2291
2286
fi
2292
2287
2293
2288
current_num=1
@@ -2305,7 +2300,8 @@ draw_processes() { #? Draw processes and values to screen
2305
2300
print -v proc_out -m $(( line+ y)) $(( col+ 1 )) -t " ${out_line:: $((width-3))} "
2306
2301
2307
2302
if (( current_num== proc[selected])) ; then print -v proc_out -rs -bg ${theme[selected_bg]} ; fi
2308
- print -v proc_out -m $(( line+ y)) $(( col+ width- 12 )) -fg $(( rgb_d- d_step)) $(( rgb_d- d_step)) $(( rgb_d- d_step)) -t " ⡀⡀⡀⡀⡀"
2303
+
2304
+ print -v proc_out -m $(( line+ y)) $(( col+ width- 12 )) -fg ${theme[inactive_fg]} -t " ⡀⡀⡀⡀⡀"
2309
2305
2310
2306
if [[ -n ${! pid_graph} ]]; then
2311
2307
print -v proc_out -m $(( line+ y)) $(( col+ width- 12 )) -fg $(( pid_r- pid_step_r)) $(( pid_g- pid_step_g)) $(( pid_b- pid_step_b)) -t " ${! pid_graph} "
@@ -2317,11 +2313,9 @@ draw_processes() { #? Draw processes and values to screen
2317
2313
if (( current_num< proc[selected]+ 1 )) ; then
2318
2314
fg_step_r=$(( fg_step_r- fg_add_r)) ; fg_step_g=$(( fg_step_g- fg_add_g)) ; fg_step_b=$(( fg_step_b- fg_add_b))
2319
2315
pid_step_r=$(( pid_step_r- pid_add_r)) ; pid_step_g=$(( pid_step_g- pid_add_g)) ; pid_step_b=$(( pid_step_b- pid_add_b))
2320
- d_step=$(( d_step- d_add))
2321
2316
elif (( current_num>= proc[selected])) ; then
2322
2317
fg_step_r=$(( fg_step_r+ fg_add_r)) ; fg_step_g=$(( fg_step_g+ fg_add_g)) ; fg_step_b=$(( fg_step_b+ fg_add_b))
2323
2318
pid_step_r=$(( pid_step_r+ pid_add_r)) ; pid_step_g=$(( pid_step_g+ pid_add_g)) ; pid_step_b=$(( pid_step_b+ pid_add_b))
2324
- d_step=$(( d_step+ d_add))
2325
2319
fi
2326
2320
2327
2321
done
@@ -2344,7 +2338,6 @@ draw_processes() { #? Draw processes and values to screen
2344
2338
if (( tty_width> 100 )) ; then
2345
2339
reverse_string=" -fg ${box[processes_color]} -t ┤ -fg ${theme[hi_fg]}${proc[reverse]: + -ul} -b -t r -fg ${theme[title]} -t everse -rs -fg ${box[processes_color]} -t ├"
2346
2340
reverse_pos=9
2347
- # unset order_left
2348
2341
fi
2349
2342
print -v proc_misc -m $line $(( col+ width- ${# proc_sorting} - 8 - reverse_pos)) -rs ${reverse_string} \
2350
2343
-fg ${box[processes_color]} -t " ┤" -fg ${theme[hi_fg]} -b -t " ‹" -fg ${theme[title]} -t " ${proc_sorting} " -fg ${theme[hi_fg]} -t " ›" -rs -fg ${box[processes_color]} -t " ├"
@@ -2498,7 +2491,7 @@ unpause_() { #? Unpause
2498
2491
}
2499
2492
2500
2493
menu_ () { # ? Shows the main menu overlay
2501
- local menu i count keypress selected_int=0 selected up local_rez d_banner=1 menu_out bannerd skipped menu_pause out_out wait_string
2494
+ local menu i count keypress selected_int=0 selected up local_rez d_banner=1 menu_out bannerd skipped menu_pause out_out wait_string trans
2502
2495
local -a menus=(" options" " help" " quit" ) color
2503
2496
2504
2497
until false ; do
@@ -2525,6 +2518,7 @@ menu_() { #? Shows the main menu overlay
2525
2518
print -v menu_out -d 1 -rs
2526
2519
selected=" ${menus[selected_int]} "
2527
2520
unset up
2521
+ if (( ${theme[main_bg_dec]// /* } > 255 ** 3 / 2 )) ; then print -v menu_out -bg " #00" ; unset trans; else trans=" -trans" ; fi
2528
2522
for menu in " ${menus[@]} " ; do
2529
2523
if [[ $menu == " $selected " ]]; then
2530
2524
local -n menu_array=" menu_${menu} _selected"
@@ -2535,10 +2529,10 @@ menu_() { #? Shows the main menu overlay
2535
2529
fi
2536
2530
up=$(( up+ ${# menu_array[@]} ))
2537
2531
for(( i= 0 ;i< ${# menu_array[@]} ;i++ )) ; do
2538
- print -v menu_out -d 1 -fg ${color[i]} -c - trans -t " ${menu_array[i]} "
2532
+ print -v menu_out -d 1 -fg ${color[i]} -c${ trans} -t " ${menu_array[i]} "
2539
2533
done
2540
2534
done
2541
- print -v menu_out -u ${up}
2535
+ print -v menu_out -rs - u ${up}
2542
2536
fi
2543
2537
unset out_out
2544
2538
out_out=" ${menu_pause}${menu_out} "
@@ -2760,21 +2754,19 @@ options_() { #? Shows the options overlay
2760
2754
fi
2761
2755
2762
2756
if [[ -n $redraw_misc ]]; then
2763
- unset options_misc
2757
+ unset options_misc redraw_misc
2764
2758
col=$(( tty_width/ 2 - 39 ))
2765
2759
line=$(( tty_height/ 2 - 4 ))
2766
2760
desc_col=$(( col+ 30 ))
2767
2761
draw_banner " $(( tty_height/ 2 - 11 )) " options_misc
2768
2762
create_box -v options_misc -w 29 -h $(( ${# options_array[@]} * 2 + 2 )) -l $line -c $(( col- 1 )) -fill -lc ${theme[div_line]} -title " options"
2769
- unset redraw_misc
2770
2763
fi
2771
2764
2772
2765
2773
2766
if [[ -n $keypress || -z $options_out ]]; then
2774
- unset options_out desc_height
2767
+ unset options_out desc_height lr inp valid
2775
2768
selected=" ${options_array[selected_int]} "
2776
2769
local -n selected_desc=" desc_${selected} "
2777
- unset lr inp valid
2778
2770
if [[ $background_update == false ]]; then desc_pos=$line ; desc_height=$(( ${# options_array[@]} * 2 + 2 ))
2779
2771
elif (( selected_int* 2 + ${# selected_desc[@]} < ${# options_array[@]} * 2 )) ; then desc_pos=$(( line+ selected_int* 2 ))
2780
2772
else desc_pos=$(( line+ ${# options_array[@]} * 2 - ${# selected_desc[@]} )) ; fi
@@ -2819,21 +2811,19 @@ options_() { #? Shows the options overlay
2819
2811
if [[ -n $theme_check ]]; then
2820
2812
local -a theme_index
2821
2813
local git_theme new_themes=0
2822
- unset ' theme_index[@]' options_out
2814
+ unset ' theme_index[@]' ' desc_color_theme[-1] ' options_out
2823
2815
theme_index=($( curl -m 3 --raw https://raw.githubusercontent.com/aristocratos/bashtop/master/themes/index.txt 2> /dev/null) )
2824
2816
if [[ ${theme_index[*]} =~ .theme ]]; then
2825
2817
for git_theme in ${theme_index[@]} ; do
2826
- if [[ ! -e " ${theme_dir} /${git_theme} " ]]; then
2818
+ if [[ $git_theme =~ .theme && ! -e " ${theme_dir} /${git_theme} " ]]; then
2827
2819
if curl -m 3 --raw " https://raw.githubusercontent.com/aristocratos/bashtop/master/themes/${git_theme} " > " ${theme_dir} /${git_theme} " 2> /dev/null; then
2828
2820
(( ++ new_themes))
2829
2821
themes+=(" ${git_theme% .theme} " )
2830
2822
fi
2831
2823
fi
2832
2824
done
2833
- unset ' desc_color_theme[-1]'
2834
2825
desc_color_theme+=(" Found ${new_themes} new theme(s)!" )
2835
2826
else
2836
- unset ' desc_color_theme[-1]'
2837
2827
desc_color_theme+=(" ERROR: Couldn't get theme index!" )
2838
2828
fi
2839
2829
fi
@@ -2984,7 +2974,7 @@ options_() { #? Shows the options overlay
2984
2974
}
2985
2975
2986
2976
killer_ () { # ? Kill process with selected signal
2987
- local kill_op=" $1 " kill_pid=" $2 " killer_out killer_box col line program keypress selected selected_int=0 sig confirmed=0 option killer_pause status status_fg msg
2977
+ local kill_op=" $1 " kill_pid=" $2 " killer_out killer_box col line program keypress selected selected_int=0 sig confirmed=0 option killer_pause status msg
2988
2978
local -a options=(" yes" " no" )
2989
2979
2990
2980
if ! program=" $( ps -o comm --no-header -p ${kill_pid} ) " ; then return ; fi
@@ -3024,8 +3014,8 @@ killer_() { #? Kill process with selected signal
3024
3014
elif (( confirmed== 1 )) ; then
3025
3015
selected=" ok"
3026
3016
print -v killer_out -m $(( line+ 2 )) $col -fg ${theme[title]} -b -jc 38 -t " Sending signal ${sig} to pid ${kill_pid} !"
3027
- print -v killer_out -m $(( line+ 4 )) $col -fg ${status_fg } -jc 38 -t " ${status^} !" -m $(( line+ 6 )) $col
3028
- if [[ -n $msg ]]; then print -v killer_out -m $(( line+ 5 )) $col -fg ee -jc 38 -t " ${msg} " -m $(( line+ 7 )) $col ; fi
3017
+ print -v killer_out -m $(( line+ 4 )) $col -fg ${theme[main_fg] } -jc 38 -t " ${status^} !" -m $(( line+ 6 )) $col
3018
+ if [[ -n $msg ]]; then print -v killer_out -m $(( line+ 5 )) $col -fg ${theme[main_fg]} -jc 38 -t " ${msg} " -m $(( line+ 7 )) $col ; fi
3029
3019
print -v killer_out -fg ${theme[selected_fg]} -bg ${theme[selected_bg]} -b -r 15 -t " [ Ok ]" -rs
3030
3020
fi
3031
3021
@@ -3065,7 +3055,6 @@ killer_() { #? Kill process with selected signal
3065
3055
elif (( confirmed> 0 )) && [[ -z $status ]]; then
3066
3056
if kill -${sig} ${kill_pid} > /dev/null 2>&1 ; then
3067
3057
status=" success"
3068
- status_fg=" 30ee20"
3069
3058
else
3070
3059
if ! ps -p ${kill_pid} > /dev/null 2>&1 ; then
3071
3060
msg=" Process not running."
@@ -3074,7 +3063,7 @@ killer_() { #? Kill process with selected signal
3074
3063
else
3075
3064
msg=" Unknown error."
3076
3065
fi
3077
- status=" failed" ; status_fg= " ee3020 " ; fi
3066
+ status=" failed" ; fi
3078
3067
fi
3079
3068
3080
3069
0 commit comments