Skip to content

Commit 3fb2230

Browse files
committed
Reduce status refresh interval by 1 second to use for CPU calculation sample interval
1 parent 295d834 commit 3fb2230

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/cpu.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ set -e
66
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
77
source "$CURRENT_DIR/helpers.sh"
88

9-
# TODO: use less than 1 second
109
refresh_interval=$(get_tmux_option "status-interval" "5")
1110

11+
# reduce interval by 1 second, so command has time to complete within tmux status refresh interval. Otherwise, tmux will use stale previous command result for 2 times in a row
12+
if [ "$refresh_interval" -gt "1" ]; then
13+
refresh_interval="$(($refresh_interval - 1))"
14+
fi
15+
1216
cpu_view_tmpl=$(get_tmux_option "@sysstat_cpu_view_tmpl" 'CPU:#[fg=#{cpu.color}]#{cpu.pused}#[default]')
1317

1418
cpu_medium_threshold=$(get_tmux_option "@sysstat_cpu_medium_threshold" "30")
@@ -57,7 +61,7 @@ print_cpu_usage() {
5761
cpu_view="${cpu_view//'#{cpu.color2}'/$(echo "$cpu_color" | awk '{ print $2 }')}"
5862
cpu_view="${cpu_view//'#{cpu.color3}'/$(echo "$cpu_color" | awk '{ print $3 }')}"
5963

60-
echo "$(date +%M:%S) $cpu_view"
64+
echo "$cpu_view"
6165
}
6266

6367
main(){

0 commit comments

Comments
 (0)