refactor: cleanup scripts

This commit is contained in:
Abhishek Keshri 2024-03-17 04:00:27 +05:30 committed by Abhishek Keshri
parent 15b06d5196
commit d2e517d76a
9 changed files with 60 additions and 160 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# setting the locale, some users have issues with different locales, this forces the correct one
export LC_ALL=en_US.UTF-8
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@ -9,7 +9,7 @@ get_percent() {
case $(uname -s) in
Linux)
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
normalize_percent_len "$percent"
normalize_padding "$percent"
;;
Darwin)
@ -17,12 +17,10 @@ get_percent() {
cpucores=$(sysctl -n hw.logicalcpu)
cpuusage=$((cpuvalue / cpucores))
percent="$cpuusage%"
normalize_percent_len $percent
normalize_padding $percent
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*)
# TODO - windows compatability
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*) ;; # TODO - windows compatibility
esac
}
@ -33,14 +31,11 @@ get_load() {
echo "$loadavg"
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*)
# TODO - windows compatability
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*) ;; # TODO - windows compatibility
esac
}
main() {
# storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@tmux2k-refresh-rate" 5)
cpu_load=$(get_tmux_option "@tmux2k-cpu-display-load" false)
if [ "$cpu_load" = true ]; then
@ -53,5 +48,4 @@ main() {
sleep "$RATE"
}
# run main driver
main