Add CPU usage module (thanks, @speedie!)

This commit is contained in:
Emily Daemon 2022-04-09 13:23:11 +03:00
parent 1b59e123c0
commit 81a74f3a95
2 changed files with 6 additions and 0 deletions

View File

@ -17,4 +17,5 @@
#module_weather "Weather: " " | " #module_weather "Weather: " " | "
#module_du "Disk Usage: " " | " #module_du "Disk Usage: " " | "
#module_ip "IP: " " | " #module_ip "IP: " " | "
#module_cpu "CPU: " " | "
module_date "Date: " "" module_date "Date: " ""

View File

@ -45,3 +45,8 @@ module_du() {
module_ip() { module_ip() {
export bar="${bar}${1}$(ip -f inet a | awk '/inet / { print $2 }' | tail -n 1 | sed 's/\/.*//')${2}" export bar="${bar}${1}$(ip -f inet a | awk '/inet / { print $2 }' | tail -n 1 | sed 's/\/.*//')${2}"
} }
module_cpu() {
# https://github.com/speediegamer/xshbar-plugins/blob/main/cpustatus.plugin
export bar="${bar}${1}$(top -bn1 | grep 'Cpu(s)' | sed 's/.*, *\([0-9.]*\)%* id.*/\1/' | awk '{print 100 - $1"%"}')${2}"
}