mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
Add CI linting (#72)
Co-authored-by: Casper da Costa-Luis <casper.dcl@physics.org>
This commit is contained in:
parent
86c0023473
commit
00ab1d2cda
12
.github/workflows/check.yml
vendored
Normal file
12
.github/workflows/check.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
name: Check
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: luizm/action-sh-checker@master
|
||||||
|
env:
|
||||||
|
SHELLCHECK_OPTS: -x
|
||||||
13
cpu.tmux
13
cpu.tmux
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
source "$CURRENT_DIR/scripts/helpers.sh"
|
source "$CURRENT_DIR/scripts/helpers.sh"
|
||||||
|
|
||||||
|
|
@ -65,16 +65,19 @@ set_tmux_option() {
|
||||||
|
|
||||||
do_interpolation() {
|
do_interpolation() {
|
||||||
local all_interpolated="$1"
|
local all_interpolated="$1"
|
||||||
for ((i=0; i<${#cpu_commands[@]}; i++)); do
|
for ((i = 0; i < ${#cpu_commands[@]}; i++)); do
|
||||||
all_interpolated=${all_interpolated//${cpu_interpolation[$i]}/${cpu_commands[$i]}}
|
all_interpolated=${all_interpolated//${cpu_interpolation[$i]}/${cpu_commands[$i]}}
|
||||||
done
|
done
|
||||||
echo "$all_interpolated"
|
echo "$all_interpolated"
|
||||||
}
|
}
|
||||||
|
|
||||||
update_tmux_option() {
|
update_tmux_option() {
|
||||||
local option=$1
|
local option
|
||||||
local option_value=$(get_tmux_option "$option")
|
local option_value
|
||||||
local new_option_value=$(do_interpolation "$option_value")
|
local new_option_value
|
||||||
|
option=$1
|
||||||
|
option_value=$(get_tmux_option "$option")
|
||||||
|
new_option_value=$(do_interpolation "$option_value")
|
||||||
set_tmux_option "$option" "$new_option_value"
|
set_tmux_option "$option" "$new_option_value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_low_bg_color=""
|
cpu_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
|
local cpu_percentage
|
||||||
local load_status=$(load_status $cpu_percentage "cpu")
|
local load_status
|
||||||
if [ $load_status == "low" ]; then
|
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||||
|
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||||
|
if [ "$load_status" == "low" ]; then
|
||||||
echo "$cpu_low_bg_color"
|
echo "$cpu_low_bg_color"
|
||||||
elif [ $load_status == "medium" ]; then
|
elif [ "$load_status" == "medium" ]; then
|
||||||
echo "$cpu_medium_bg_color"
|
echo "$cpu_medium_bg_color"
|
||||||
elif [ $load_status == "high" ]; then
|
elif [ "$load_status" == "high" ]; then
|
||||||
echo "$cpu_high_bg_color"
|
echo "$cpu_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_bg_color_settings
|
get_bg_color_settings
|
||||||
print_bg_color
|
print_bg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_low_fg_color=""
|
cpu_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
|
local cpu_percentage
|
||||||
local load_status=$(load_status $cpu_percentage "cpu")
|
local load_status
|
||||||
if [ $load_status == "low" ]; then
|
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||||
|
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||||
|
if [ "$load_status" == "low" ]; then
|
||||||
echo "$cpu_low_fg_color"
|
echo "$cpu_low_fg_color"
|
||||||
elif [ $load_status == "medium" ]; then
|
elif [ "$load_status" == "medium" ]; then
|
||||||
echo "$cpu_medium_fg_color"
|
echo "$cpu_medium_fg_color"
|
||||||
elif [ $load_status == "high" ]; then
|
elif [ "$load_status" == "high" ]; then
|
||||||
echo "$cpu_high_fg_color"
|
echo "$cpu_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_fg_color_settings
|
get_fg_color_settings
|
||||||
print_fg_color
|
print_fg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//')
|
local cpu_percentage
|
||||||
local load_status=$(load_status $cpu_percentage "cpu")
|
local load_status
|
||||||
if [ $load_status == "low" ]; then
|
cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//')
|
||||||
|
load_status=$(load_status "$cpu_percentage" "cpu")
|
||||||
|
if [ "$load_status" == "low" ]; then
|
||||||
echo "$cpu_low_icon"
|
echo "$cpu_low_icon"
|
||||||
elif [ $load_status == "medium" ]; then
|
elif [ "$load_status" == "medium" ]; then
|
||||||
echo "$cpu_medium_icon"
|
echo "$cpu_medium_icon"
|
||||||
elif [ $load_status == "high" ]; then
|
elif [ "$load_status" == "high" ]; then
|
||||||
echo "$cpu_high_icon"
|
echo "$cpu_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_percentage_format="%3.1f%%"
|
cpu_percentage_format="%3.1f%%"
|
||||||
|
|
@ -25,9 +26,10 @@ print_cpu_percentage() {
|
||||||
else
|
else
|
||||||
if is_cygwin; then
|
if is_cygwin; then
|
||||||
usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')"
|
usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')"
|
||||||
|
# shellcheck disable=SC2059
|
||||||
printf "$cpu_percentage_format" "$usage"
|
printf "$cpu_percentage_format" "$usage"
|
||||||
else
|
else
|
||||||
load=`cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}'`
|
load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}')
|
||||||
cpus=$(cpus_number)
|
cpus=$(cpus_number)
|
||||||
echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}'
|
echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_temp_format="%2.0f"
|
cpu_temp_format="%2.0f"
|
||||||
|
|
@ -11,7 +12,13 @@ print_cpu_temp() {
|
||||||
cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format")
|
cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format")
|
||||||
cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit")
|
cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit")
|
||||||
if command_exists "sensors"; then
|
if command_exists "sensors"; then
|
||||||
([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
|
local val
|
||||||
|
if [[ "$cpu_temp_unit" == F ]]; then
|
||||||
|
val=$(sensors -f)
|
||||||
|
else
|
||||||
|
val=$(sensors)
|
||||||
|
fi
|
||||||
|
val | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_temp_low_bg_color=""
|
cpu_temp_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
local cpu_temp
|
||||||
local cpu_temp_status=$(temp_status $cpu_temp)
|
local cpu_temp_status
|
||||||
if [ $cpu_temp_status == "low" ]; then
|
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||||
|
if [ "$cpu_temp_status" == "low" ]; then
|
||||||
echo "$cpu_temp_low_bg_color"
|
echo "$cpu_temp_low_bg_color"
|
||||||
elif [ $cpu_temp_status == "medium" ]; then
|
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||||
echo "$cpu_temp_medium_bg_color"
|
echo "$cpu_temp_medium_bg_color"
|
||||||
elif [ $cpu_temp_status == "high" ]; then
|
elif [ "$cpu_temp_status" == "high" ]; then
|
||||||
echo "$cpu_temp_high_bg_color"
|
echo "$cpu_temp_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
cpu_temp_low_fg_color=""
|
cpu_temp_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
local cpu_temp
|
||||||
local cpu_temp_status=$(temp_status $cpu_temp)
|
local cpu_temp_status
|
||||||
if [ $cpu_temp_status == "low" ]; then
|
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||||
|
if [ "$cpu_temp_status" == "low" ]; then
|
||||||
echo "$cpu_temp_low_fg_color"
|
echo "$cpu_temp_low_fg_color"
|
||||||
elif [ $cpu_temp_status == "medium" ]; then
|
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||||
echo "$cpu_temp_medium_fg_color"
|
echo "$cpu_temp_medium_fg_color"
|
||||||
elif [ $cpu_temp_status == "high" ]; then
|
elif [ "$cpu_temp_status" == "high" ]; then
|
||||||
echo "$cpu_temp_high_fg_color"
|
echo "$cpu_temp_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
local cpu_temp
|
||||||
local cpu_temp_status=$(temp_status $cpu_temp)
|
local cpu_temp_status
|
||||||
if [ $cpu_temp_status == "low" ]; then
|
cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
cpu_temp_status=$(temp_status "$cpu_temp")
|
||||||
|
if [ "$cpu_temp_status" == "low" ]; then
|
||||||
echo "$cpu_temp_low_icon"
|
echo "$cpu_temp_low_icon"
|
||||||
elif [ $cpu_temp_status == "medium" ]; then
|
elif [ "$cpu_temp_status" == "medium" ]; then
|
||||||
echo "$cpu_temp_medium_icon"
|
echo "$cpu_temp_medium_icon"
|
||||||
elif [ $cpu_temp_status == "high" ]; then
|
elif [ "$cpu_temp_status" == "high" ]; then
|
||||||
echo "$cpu_temp_high_icon"
|
echo "$cpu_temp_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_low_bg_color=""
|
gpu_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
|
local gpu_percentage
|
||||||
local gpu_load_status=$(load_status $gpu_percentage "gpu")
|
local gpu_load_status
|
||||||
if [ $gpu_load_status == "low" ]; then
|
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||||
|
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||||
|
if [ "$gpu_load_status" == "low" ]; then
|
||||||
echo "$gpu_low_bg_color"
|
echo "$gpu_low_bg_color"
|
||||||
elif [ $gpu_load_status == "medium" ]; then
|
elif [ "$gpu_load_status" == "medium" ]; then
|
||||||
echo "$gpu_medium_bg_color"
|
echo "$gpu_medium_bg_color"
|
||||||
elif [ $gpu_load_status == "high" ]; then
|
elif [ "$gpu_load_status" == "high" ]; then
|
||||||
echo "$gpu_high_bg_color"
|
echo "$gpu_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_bg_color_settings
|
get_bg_color_settings
|
||||||
print_bg_color
|
print_bg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_low_fg_color=""
|
gpu_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
|
local gpu_percentage
|
||||||
local gpu_load_status=$(load_status $gpu_percentage "gpu")
|
local gpu_load_status
|
||||||
if [ $gpu_load_status == "low" ]; then
|
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||||
|
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||||
|
if [ "$gpu_load_status" == "low" ]; then
|
||||||
echo "$gpu_low_fg_color"
|
echo "$gpu_low_fg_color"
|
||||||
elif [ $gpu_load_status == "medium" ]; then
|
elif [ "$gpu_load_status" == "medium" ]; then
|
||||||
echo "$gpu_medium_fg_color"
|
echo "$gpu_medium_fg_color"
|
||||||
elif [ $gpu_load_status == "high" ]; then
|
elif [ "$gpu_load_status" == "high" ]; then
|
||||||
echo "$gpu_high_fg_color"
|
echo "$gpu_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_fg_color_settings
|
get_fg_color_settings
|
||||||
print_fg_color
|
print_fg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//')
|
local gpu_percentage
|
||||||
local gpu_load_status=$(load_status $gpu_percentage "gpu")
|
local gpu_load_status
|
||||||
if [ $gpu_load_status == "low" ]; then
|
gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//')
|
||||||
|
gpu_load_status=$(load_status "$gpu_percentage" "gpu")
|
||||||
|
if [ "$gpu_load_status" == "low" ]; then
|
||||||
echo "$gpu_low_icon"
|
echo "$gpu_low_icon"
|
||||||
elif [ $gpu_load_status == "medium" ]; then
|
elif [ "$gpu_load_status" == "medium" ]; then
|
||||||
echo "$gpu_medium_icon"
|
echo "$gpu_medium_icon"
|
||||||
elif [ $gpu_load_status == "high" ]; then
|
elif [ "$gpu_load_status" == "high" ]; then
|
||||||
echo "$gpu_high_icon"
|
echo "$gpu_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_percentage_format="%3.1f%%"
|
gpu_percentage_format="%3.1f%%"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_temp_format="%2.0f"
|
gpu_temp_format="%2.0f"
|
||||||
|
|
@ -20,7 +21,7 @@ print_gpu_temp() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
tempC=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk '{sum+=$1; n+=1} END {printf "%5.3f", sum/n}')
|
tempC=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk '{sum+=$1; n+=1} END {printf "%5.3f", sum/n}')
|
||||||
if [ $gpu_temp_unit == "C" ]; then
|
if [ "$gpu_temp_unit" == "C" ]; then
|
||||||
echo "$tempC" | awk -v format="${gpu_temp_format}C" '{sum+=$1} END {printf format, sum}'
|
echo "$tempC" | awk -v format="${gpu_temp_format}C" '{sum+=$1} END {printf format, sum}'
|
||||||
else
|
else
|
||||||
echo "$tempC" | awk -v format="${gpu_temp_format}F" '{sum+=$1} END {printf format, sum*9/5+32}'
|
echo "$tempC" | awk -v format="${gpu_temp_format}F" '{sum+=$1} END {printf format, sum*9/5+32}'
|
||||||
|
|
@ -30,4 +31,4 @@ print_gpu_temp() {
|
||||||
main() {
|
main() {
|
||||||
print_gpu_temp
|
print_gpu_temp
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_temp_low_bg_color=""
|
gpu_temp_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
local gpu_temp
|
||||||
local gpu_temp_status=$(temp_status $gpu_temp)
|
local gpu_temp_status
|
||||||
if [ $gpu_temp_status == "low" ]; then
|
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||||
|
if [ "$gpu_temp_status" == "low" ]; then
|
||||||
echo "$gpu_temp_low_bg_color"
|
echo "$gpu_temp_low_bg_color"
|
||||||
elif [ $gpu_temp_status == "medium" ]; then
|
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||||
echo "$gpu_temp_medium_bg_color"
|
echo "$gpu_temp_medium_bg_color"
|
||||||
elif [ $gpu_temp_status == "high" ]; then
|
elif [ "$gpu_temp_status" == "high" ]; then
|
||||||
echo "$gpu_temp_high_bg_color"
|
echo "$gpu_temp_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_bg_color_settings
|
get_bg_color_settings
|
||||||
print_bg_color
|
print_bg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gpu_temp_low_fg_color=""
|
gpu_temp_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
local gpu_temp
|
||||||
local gpu_temp_status=$(temp_status $gpu_temp)
|
local gpu_temp_status
|
||||||
if [ $gpu_temp_status == "low" ]; then
|
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||||
|
if [ "$gpu_temp_status" == "low" ]; then
|
||||||
echo "$gpu_temp_low_fg_color"
|
echo "$gpu_temp_low_fg_color"
|
||||||
elif [ $gpu_temp_status == "medium" ]; then
|
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||||
echo "$gpu_temp_medium_fg_color"
|
echo "$gpu_temp_medium_fg_color"
|
||||||
elif [ $gpu_temp_status == "high" ]; then
|
elif [ "$gpu_temp_status" == "high" ]; then
|
||||||
echo "$gpu_temp_high_fg_color"
|
echo "$gpu_temp_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_fg_color_settings
|
get_fg_color_settings
|
||||||
print_fg_color
|
print_fg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
local gpu_temp
|
||||||
local gpu_temp_status=$(temp_status $gpu_temp)
|
local gpu_temp_status
|
||||||
if [ $gpu_temp_status == "low" ]; then
|
gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//')
|
||||||
|
gpu_temp_status=$(temp_status "$gpu_temp")
|
||||||
|
if [ "$gpu_temp_status" == "low" ]; then
|
||||||
echo "$gpu_temp_low_icon"
|
echo "$gpu_temp_low_icon"
|
||||||
elif [ $gpu_temp_status == "medium" ]; then
|
elif [ "$gpu_temp_status" == "medium" ]; then
|
||||||
echo "$gpu_temp_medium_icon"
|
echo "$gpu_temp_medium_icon"
|
||||||
elif [ $gpu_temp_status == "high" ]; then
|
elif [ "$gpu_temp_status" == "high" ]; then
|
||||||
echo "$gpu_temp_high_icon"
|
echo "$gpu_temp_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gram_low_bg_color=""
|
gram_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
|
local gram_percentage
|
||||||
local gram_load_status=$(load_status $gram_percentage "gram")
|
local gram_load_status
|
||||||
if [ $gram_load_status == "low" ]; then
|
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||||
|
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||||
|
if [ "$gram_load_status" == "low" ]; then
|
||||||
echo "$gram_low_bg_color"
|
echo "$gram_low_bg_color"
|
||||||
elif [ $gram_load_status == "medium" ]; then
|
elif [ "$gram_load_status" == "medium" ]; then
|
||||||
echo "$gram_medium_bg_color"
|
echo "$gram_medium_bg_color"
|
||||||
elif [ $gram_load_status == "high" ]; then
|
elif [ "$gram_load_status" == "high" ]; then
|
||||||
echo "$gram_high_bg_color"
|
echo "$gram_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_bg_color_settings
|
get_bg_color_settings
|
||||||
print_bg_color
|
print_bg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gram_low_fg_color=""
|
gram_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
|
local gram_percentage
|
||||||
local gram_load_status=$(load_status $gram_percentage "gram")
|
local gram_load_status
|
||||||
if [ $gram_load_status == "low" ]; then
|
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||||
|
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||||
|
if [ "$gram_load_status" == "low" ]; then
|
||||||
echo "$gram_low_fg_color"
|
echo "$gram_low_fg_color"
|
||||||
elif [ $gram_load_status == "medium" ]; then
|
elif [ "$gram_load_status" == "medium" ]; then
|
||||||
echo "$gram_medium_fg_color"
|
echo "$gram_medium_fg_color"
|
||||||
elif [ $gram_load_status == "high" ]; then
|
elif [ "$gram_load_status" == "high" ]; then
|
||||||
echo "$gram_high_fg_color"
|
echo "$gram_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -34,4 +37,4 @@ main() {
|
||||||
get_fg_color_settings
|
get_fg_color_settings
|
||||||
print_fg_color
|
print_fg_color
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//')
|
local gram_percentage
|
||||||
local gram_load_status=$(load_status $gram_percentage "gram")
|
local gram_load_status
|
||||||
if [ $gram_load_status == "low" ]; then
|
gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//')
|
||||||
|
gram_load_status=$(load_status "$gram_percentage" "gram")
|
||||||
|
if [ "$gram_load_status" == "low" ]; then
|
||||||
echo "$gram_low_icon"
|
echo "$gram_low_icon"
|
||||||
elif [ $gram_load_status == "medium" ]; then
|
elif [ "$gram_load_status" == "medium" ]; then
|
||||||
echo "$gram_medium_icon"
|
echo "$gram_medium_icon"
|
||||||
elif [ $gram_load_status == "high" ]; then
|
elif [ "$gram_load_status" == "high" ]; then
|
||||||
echo "$gram_high_icon"
|
echo "$gram_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
gram_percentage_format="%3.1f%%"
|
gram_percentage_format="%3.1f%%"
|
||||||
|
|
@ -23,4 +24,4 @@ print_gram_percentage() {
|
||||||
main() {
|
main() {
|
||||||
print_gram_percentage
|
print_gram_percentage
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export LANG=C
|
export LANG=C
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
|
||||||
get_tmux_option() {
|
get_tmux_option() {
|
||||||
local option="$1"
|
local option
|
||||||
local default_value="$2"
|
local default_value
|
||||||
local option_value="$(tmux show-option -qv "$option")"
|
local option_value
|
||||||
|
option="$1"
|
||||||
|
default_value="$2"
|
||||||
|
option_value="$(tmux show-option -qv "$option")"
|
||||||
if [ -z "$option_value" ]; then
|
if [ -z "$option_value" ]; then
|
||||||
option_value="$(tmux show-option -gqv "$option")"
|
option_value="$(tmux show-option -gqv "$option")"
|
||||||
fi
|
fi
|
||||||
|
|
@ -16,33 +21,33 @@ get_tmux_option() {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_osx() {
|
is_osx() {
|
||||||
[ $(uname) == "Darwin" ]
|
[ "$(uname)" == "Darwin" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_freebsd() {
|
is_freebsd() {
|
||||||
[ $(uname) == "FreeBSD" ]
|
[ "$(uname)" == "FreeBSD" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_openbsd() {
|
is_openbsd() {
|
||||||
[ $(uname) == "OpenBSD" ]
|
[ "$(uname)" == "OpenBSD" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_linux() {
|
is_linux() {
|
||||||
[ $(uname) == "Linux" ]
|
[ "$(uname)" == "Linux" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_cygwin() {
|
is_cygwin() {
|
||||||
command -v WMIC &> /dev/null
|
command -v WMIC &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
is_linux_iostat() {
|
is_linux_iostat() {
|
||||||
# Bug in early versions of linux iostat -V return error code
|
# Bug in early versions of linux iostat -V return error code
|
||||||
iostat -c &> /dev/null
|
iostat -c &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# is second float bigger or equal?
|
# is second float bigger or equal?
|
||||||
fcomp() {
|
fcomp() {
|
||||||
awk -v n1=$1 -v n2=$2 'BEGIN {if (n1<=n2) exit 0; exit 1}'
|
awk -v n1="$1" -v n2="$2" 'BEGIN {if (n1<=n2) exit 0; exit 1}'
|
||||||
}
|
}
|
||||||
|
|
||||||
load_status() {
|
load_status() {
|
||||||
|
|
@ -50,9 +55,9 @@ load_status() {
|
||||||
local prefix=$2
|
local prefix=$2
|
||||||
medium_thresh=$(get_tmux_option "@${prefix}_medium_thresh" "30")
|
medium_thresh=$(get_tmux_option "@${prefix}_medium_thresh" "30")
|
||||||
high_thresh=$(get_tmux_option "@${prefix}_high_thresh" "80")
|
high_thresh=$(get_tmux_option "@${prefix}_high_thresh" "80")
|
||||||
if fcomp $high_thresh $percentage; then
|
if fcomp "$high_thresh" "$percentage"; then
|
||||||
echo "high"
|
echo "high"
|
||||||
elif fcomp $medium_thresh $percentage && fcomp $percentage $high_thresh; then
|
elif fcomp "$medium_thresh" "$percentage" && fcomp "$percentage" "$high_thresh"; then
|
||||||
echo "medium"
|
echo "medium"
|
||||||
else
|
else
|
||||||
echo "low"
|
echo "low"
|
||||||
|
|
@ -60,12 +65,13 @@ load_status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_status() {
|
temp_status() {
|
||||||
local temp=$1
|
local temp
|
||||||
|
temp=$1
|
||||||
cpu_temp_medium_thresh=$(get_tmux_option "@cpu_temp_medium_thresh" "80")
|
cpu_temp_medium_thresh=$(get_tmux_option "@cpu_temp_medium_thresh" "80")
|
||||||
cpu_temp_high_thresh=$(get_tmux_option "@cpu_temp_high_thresh" "90")
|
cpu_temp_high_thresh=$(get_tmux_option "@cpu_temp_high_thresh" "90")
|
||||||
if fcomp $cpu_temp_high_thresh $temp; then
|
if fcomp "$cpu_temp_high_thresh" "$temp"; then
|
||||||
echo "high"
|
echo "high"
|
||||||
elif fcomp $cpu_temp_medium_thresh $temp && fcomp $temp $cpu_temp_high_thresh; then
|
elif fcomp "$cpu_temp_medium_thresh" "$temp" && fcomp "$temp" "$cpu_temp_high_thresh"; then
|
||||||
echo "medium"
|
echo "medium"
|
||||||
else
|
else
|
||||||
echo "low"
|
echo "low"
|
||||||
|
|
@ -77,7 +83,7 @@ cpus_number() {
|
||||||
if command_exists "nproc"; then
|
if command_exists "nproc"; then
|
||||||
nproc
|
nproc
|
||||||
else
|
else
|
||||||
echo "$(( $(sed -n 's/^processor.*:\s*\([0-9]\+\)/\1/p' /proc/cpuinfo | tail -n 1) + 1 ))"
|
echo "$(($(sed -n 's/^processor.*:\s*\([0-9]\+\)/\1/p' /proc/cpuinfo | tail -n 1) + 1))"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sysctl -n hw.ncpu
|
sysctl -n hw.ncpu
|
||||||
|
|
@ -85,12 +91,14 @@ cpus_number() {
|
||||||
}
|
}
|
||||||
|
|
||||||
command_exists() {
|
command_exists() {
|
||||||
local command="$1"
|
local command
|
||||||
command -v "$command" &> /dev/null
|
command="$1"
|
||||||
|
command -v "$command" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
get_tmp_dir() {
|
get_tmp_dir() {
|
||||||
local tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
|
local tmpdir
|
||||||
|
tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}"
|
||||||
[ -d "$tmpdir" ] || local tmpdir=~/tmp
|
[ -d "$tmpdir" ] || local tmpdir=~/tmp
|
||||||
echo "$tmpdir/tmux-$EUID-cpu"
|
echo "$tmpdir/tmux-$EUID-cpu"
|
||||||
}
|
}
|
||||||
|
|
@ -99,32 +107,41 @@ get_time() {
|
||||||
date +%s.%N
|
date +%s.%N
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cache_val(){
|
get_cache_val() {
|
||||||
local key="$1"
|
local key
|
||||||
|
local timeout
|
||||||
|
local cache
|
||||||
|
key="$1"
|
||||||
# seconds after which cache is invalidated
|
# seconds after which cache is invalidated
|
||||||
local timeout="${2:-2}"
|
timeout="${2:-2}"
|
||||||
local cache="$(get_tmp_dir)/$key"
|
cache="$(get_tmp_dir)/$key"
|
||||||
if [ -f "$cache" ]; then
|
if [ -f "$cache" ]; then
|
||||||
awk -v cache="$(head -n1 "$cache")" -v timeout=$timeout -v now=$(get_time) \
|
awk -v cache="$(head -n1 "$cache")" -v timeout="$timeout" -v now="$(get_time)" \
|
||||||
'BEGIN {if (now - timeout < cache) exit 0; exit 1}' \
|
'BEGIN {if (now - timeout < cache) exit 0; exit 1}' &&
|
||||||
&& tail -n+2 "$cache"
|
tail -n+2 "$cache"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
put_cache_val(){
|
put_cache_val() {
|
||||||
local key="$1"
|
local key
|
||||||
local val="${@:2}"
|
local val
|
||||||
local tmpdir="$(get_tmp_dir)"
|
local tmpdir
|
||||||
|
key="$1"
|
||||||
|
val="$2"
|
||||||
|
tmpdir="$(get_tmp_dir)"
|
||||||
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
|
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
|
||||||
echo "$(get_time)" > "$tmpdir/$key"
|
get_time >"$tmpdir/$key"
|
||||||
echo -n "$val" >> "$tmpdir/$key"
|
echo -n "$val" >>"$tmpdir/$key"
|
||||||
echo -n "$val"
|
echo -n "$val"
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_eval(){
|
cached_eval() {
|
||||||
local command="$1"
|
local command
|
||||||
local key="$(basename "$command")"
|
local key
|
||||||
local val="$(get_cache_val "$key")"
|
local val
|
||||||
|
command="$1"
|
||||||
|
key="$(basename "$command")"
|
||||||
|
val="$(get_cache_val "$key")"
|
||||||
if [ -z "$val" ]; then
|
if [ -z "$val" ]; then
|
||||||
put_cache_val "$key" "$($command "${@:2}")"
|
put_cache_val "$key" "$($command "${@:2}")"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
ram_low_bg_color=""
|
ram_low_bg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_bg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_bg_color() {
|
print_bg_color() {
|
||||||
local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
|
local ram_percentage
|
||||||
local ram_load_status=$(load_status $ram_percentage "ram")
|
local ram_load_status
|
||||||
if [ $ram_load_status == "low" ]; then
|
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||||
|
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||||
|
if [ "$ram_load_status" == "low" ]; then
|
||||||
echo "$ram_low_bg_color"
|
echo "$ram_low_bg_color"
|
||||||
elif [ $ram_load_status == "medium" ]; then
|
elif [ "$ram_load_status" == "medium" ]; then
|
||||||
echo "$ram_medium_bg_color"
|
echo "$ram_medium_bg_color"
|
||||||
elif [ $ram_load_status == "high" ]; then
|
elif [ "$ram_load_status" == "high" ]; then
|
||||||
echo "$ram_high_bg_color"
|
echo "$ram_high_bg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
ram_low_fg_color=""
|
ram_low_fg_color=""
|
||||||
|
|
@ -19,13 +20,15 @@ get_fg_color_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_fg_color() {
|
print_fg_color() {
|
||||||
local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
|
local ram_percentage
|
||||||
local ram_load_status=$(load_status $ram_percentage "ram")
|
local ram_load_status
|
||||||
if [ $ram_load_status == "low" ]; then
|
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||||
|
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||||
|
if [ "$ram_load_status" == "low" ]; then
|
||||||
echo "$ram_low_fg_color"
|
echo "$ram_low_fg_color"
|
||||||
elif [ $ram_load_status == "medium" ]; then
|
elif [ "$ram_load_status" == "medium" ]; then
|
||||||
echo "$ram_medium_fg_color"
|
echo "$ram_medium_fg_color"
|
||||||
elif [ $ram_load_status == "high" ]; then
|
elif [ "$ram_load_status" == "high" ]; then
|
||||||
echo "$ram_high_fg_color"
|
echo "$ram_high_fg_color"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
# script global variables
|
# script global variables
|
||||||
|
|
@ -21,13 +22,15 @@ get_icon_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_icon() {
|
print_icon() {
|
||||||
local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//')
|
local ram_percentage
|
||||||
local ram_load_status=$(load_status $ram_percentage "ram")
|
local ram_load_status
|
||||||
if [ $ram_load_status == "low" ]; then
|
ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//')
|
||||||
|
ram_load_status=$(load_status "$ram_percentage" "ram")
|
||||||
|
if [ "$ram_load_status" == "low" ]; then
|
||||||
echo "$ram_low_icon"
|
echo "$ram_low_icon"
|
||||||
elif [ $ram_load_status == "medium" ]; then
|
elif [ "$ram_load_status" == "medium" ]; then
|
||||||
echo "$ram_medium_icon"
|
echo "$ram_medium_icon"
|
||||||
elif [ $ram_load_status == "high" ]; then
|
elif [ "$ram_load_status" == "high" ]; then
|
||||||
echo "$ram_high_icon"
|
echo "$ram_high_icon"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -36,4 +39,4 @@ main() {
|
||||||
get_icon_settings
|
get_icon_settings
|
||||||
print_icon "$1"
|
print_icon "$1"
|
||||||
}
|
}
|
||||||
main
|
main "$@"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# shellcheck source=scripts/helpers.sh
|
||||||
source "$CURRENT_DIR/helpers.sh"
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
|
||||||
ram_percentage_format="%3.1f%%"
|
ram_percentage_format="%3.1f%%"
|
||||||
|
|
||||||
sum_macos_vm_stats() {
|
sum_macos_vm_stats() {
|
||||||
grep -Eo '[0-9]+' \
|
grep -Eo '[0-9]+' |
|
||||||
| awk '{ a += $1 * 4096 } END { print a }'
|
awk '{ a += $1 * 4096 } END { print a }'
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ram_percentage() {
|
print_ram_percentage() {
|
||||||
|
|
@ -20,23 +21,26 @@ print_ram_percentage() {
|
||||||
# page size of 4096 bytes
|
# page size of 4096 bytes
|
||||||
stats="$(cached_eval vm_stat)"
|
stats="$(cached_eval vm_stat)"
|
||||||
|
|
||||||
used_and_cached=$(echo "$stats" \
|
used_and_cached=$(
|
||||||
| grep -E "(Pages active|Pages inactive|Pages speculative|Pages wired down|Pages occupied by compressor)" \
|
echo "$stats" |
|
||||||
| sum_macos_vm_stats \
|
grep -E "(Pages active|Pages inactive|Pages speculative|Pages wired down|Pages occupied by compressor)" |
|
||||||
|
sum_macos_vm_stats
|
||||||
)
|
)
|
||||||
|
|
||||||
cached=$(echo "$stats" \
|
cached=$(
|
||||||
| grep -E "(Pages purgeable|File-backed pages)" \
|
echo "$stats" |
|
||||||
| sum_macos_vm_stats \
|
grep -E "(Pages purgeable|File-backed pages)" |
|
||||||
|
sum_macos_vm_stats
|
||||||
)
|
)
|
||||||
|
|
||||||
free=$(echo "$stats" \
|
free=$(
|
||||||
| grep -E "(Pages free)" \
|
echo "$stats" |
|
||||||
| sum_macos_vm_stats \
|
grep -E "(Pages free)" |
|
||||||
|
sum_macos_vm_stats
|
||||||
)
|
)
|
||||||
|
|
||||||
used=$(($used_and_cached - $cached))
|
used=$((used_and_cached - cached))
|
||||||
total=$(($used_and_cached + $free))
|
total=$((used_and_cached + free))
|
||||||
|
|
||||||
echo "$used $total" | awk -v format="$ram_percentage_format" '{printf(format, 100*$1/$2)}'
|
echo "$used $total" | awk -v format="$ram_percentage_format" '{printf(format, 100*$1/$2)}'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue