You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
641 B
30 lines
641 B
5 years ago
|
#!/bin/bash
|
||
|
# helpers for tmux status line scripts
|
||
|
|
||
|
function get_bgcolor_gradient_red_to_cyan() {
|
||
|
local -a colors
|
||
|
colors=(
|
||
|
196 # red
|
||
|
202 208 214 220 # oranges
|
||
|
226 226 # yellow
|
||
|
190 154 118 # yellow-greens
|
||
|
046 046 046 # green
|
||
|
047 048 049 050 # green-cyans
|
||
|
051 # cyan
|
||
|
)
|
||
5 years ago
|
local curval=${1:-0}
|
||
|
local maxval=${2:-100}
|
||
|
local maxindex=$(( ${#colors[@]} - 1 ))
|
||
|
local index=$(( (curval * maxindex) / maxval ))
|
||
5 years ago
|
if [[ $index -gt $maxindex ]]; then
|
||
|
index=$maxindex
|
||
|
elif [[ $index -lt 0 ]]; then
|
||
|
index=0
|
||
|
fi
|
||
5 years ago
|
echo ${colors[$index]}
|
||
5 years ago
|
}
|
||
|
|
||
|
function needs_reboot() {
|
||
|
[[ -f //var/run/reboot-required ]]
|
||
|
}
|