diff --git a/config.sh b/config.sh index bc87d89..f5841ad 100755 --- a/config.sh +++ b/config.sh @@ -17,4 +17,5 @@ #module_weather "Weather: " " | " #module_du "Disk Usage: " " | " #module_ip "IP: " " | " +#module_cpu "CPU: " " | " module_date "Date: " "" diff --git a/modules.sh b/modules.sh index 6fc1c3a..98d82b0 100755 --- a/modules.sh +++ b/modules.sh @@ -45,3 +45,8 @@ module_du() { module_ip() { 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}" +}