Skip to content

Commit 257bc1f

Browse files
Merge pull request dracula#143 from adrianmihalko/master
Add load average support
2 parents a098a4f + 5535270 commit 257bc1f

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

INSTALL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ Customize label
119119
set -g @dracula-cpu-usage-label "CPU"
120120
```
121121

122+
Show system load average instead of CPU usage percentage (default)
123+
124+
```bash
125+
set -g @dracula-cpu-display-load true
126+
```
127+
128+
CPU usage percentage (default) - in percentage (output: %)
129+
Load average – is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x)
130+
122131
#### gpu-usage options
123132

124133
Customize label

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
2121
* Git branch and status
2222
* Battery percentage and AC power connection status
2323
* Refresh rate control
24-
* CPU usage
24+
* CPU usage (percentage or load average)
2525
* RAM usage
2626
* GPU usage
2727
* Color code based on if prefix is active or not

scripts/cpu_info.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,30 @@ get_percent()
2727
esac
2828
}
2929

30-
main()
31-
{
30+
get_load() {
31+
case $(uname -s) in
32+
Linux | Darwin)
33+
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
34+
echo $loadavg
35+
;;
36+
37+
CYGWIN* | MINGW32* | MSYS* | MINGW*)
38+
# TODO - windows compatability
39+
;;
40+
esac
41+
}
42+
43+
main() {
3244
# storing the refresh rate in the variable RATE, default is 5
3345
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
34-
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
35-
cpu_percent=$(get_percent)
36-
echo "$cpu_label $cpu_percent"
46+
cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false)
47+
if [ "$cpu_load" = true ]; then
48+
echo "$(get_load)"
49+
else
50+
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
51+
cpu_percent=$(get_percent)
52+
echo "$cpu_label $cpu_percent"
53+
fi
3754
sleep $RATE
3855
}
3956

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy