From 23e75213902006cadbf8ba404ec99955dec7c1fb Mon Sep 17 00:00:00 2001 From: q3aql Date: Sun, 14 Nov 2021 22:44:33 +0100 Subject: [PATCH] i3blocks (CPU load) --- .config/i3blocks/config | 2 +- .config/i3blocks/cpu/cpu_info.sh | 6 +- .config/i3blocks/cpu/cpu_load.sh | 83 +++++ .config/i3blocks/weather/forecast.xml | 450 +++++++++++++------------- 4 files changed, 312 insertions(+), 229 deletions(-) create mode 100755 .config/i3blocks/cpu/cpu_load.sh diff --git a/.config/i3blocks/config b/.config/i3blocks/config index 856e08e..6dce243 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -20,7 +20,7 @@ color=#C9E3DB [CPU] full_text= CPU: 0.00% @ +00.0°C command=~/.config/i3blocks/cpu/cpu_info.sh -interval=repeat +interval=2 color=#00B4EB [MEM] diff --git a/.config/i3blocks/cpu/cpu_info.sh b/.config/i3blocks/cpu/cpu_info.sh index 84b0783..68b8e9c 100755 --- a/.config/i3blocks/cpu/cpu_info.sh +++ b/.config/i3blocks/cpu/cpu_info.sh @@ -1,5 +1,5 @@ #!/bin/sh TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) -CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') -#CPU_USAGE=$(mpstat | tr -s " " | cut -d " " -f 13 | tail -1) -echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s% @ %s \n"), $1, $2 }' +#CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') +CPU_USAGE=$(~/.config/i3blocks/cpu/cpu_load.sh -p) +echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' diff --git a/.config/i3blocks/cpu/cpu_load.sh b/.config/i3blocks/cpu/cpu_load.sh new file mode 100755 index 0000000..57fc7e5 --- /dev/null +++ b/.config/i3blocks/cpu/cpu_load.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Script to show cpu +# Created by q3aql (q3aql@protonmail.ch) +# Licensed by GPL v.2 +# Date: 10-01-2020 +# -------------------------------------- +VERSION="1.0" + + +# Variables +cpuPercentage=$(top -b -n1 | grep \%Cpu | awk '{print 100-$8}') +showCpuPercentage=$(echo ${cpuPercentage}) +showCpuPercentageInteger=$(echo ${showCpuPercentage} | cut -d "." -f 1) + +# Show percentage bar +if [ ${showCpuPercentageInteger} -ge 0 ] ; then + showCpuPercentageBar="=" +fi +if [ ${showCpuPercentageInteger} -ge 3 ] ; then + showCpuPercentageBar="==" +fi +if [ ${showCpuPercentageInteger} -ge 12 ] ; then + showCpuPercentageBar="===" +fi +if [ ${showCpuPercentageInteger} -ge 18 ] ; then + showCpuPercentageBar="====" +fi +if [ ${showCpuPercentageInteger} -ge 25 ] ; then + showCpuPercentageBar="=====" +fi +if [ ${showCpuPercentageInteger} -ge 35 ] ; then + showCpuPercentageBar="======" +fi +if [ ${showCpuPercentageInteger} -ge 40 ] ; then + showCpuPercentageBar="=======" +fi +if [ ${showCpuPercentageInteger} -ge 45 ] ; then + showCpuPercentageBar="========" +fi +if [ ${showCpuPercentageInteger} -ge 50 ] ; then + showCpuPercentageBar="==========" +fi +if [ ${showCpuPercentageInteger} -ge 62 ] ; then + showCpuPercentageBar="=============" +fi +if [ ${showCpuPercentageInteger} -ge 75 ] ; then + showCpuPercentageBar="===============" +fi +if [ ${showCpuPercentageInteger} -ge 85 ] ; then + showCpuPercentageBar="=================" +fi +if [ ${showCpuPercentageInteger} -ge 90 ] ; then + showCpuPercentageBar="==================" +fi +if [ ${showCpuPercentageInteger} -ge 95 ] ; then + showCpuPercentageBar="===================" +fi +if [ ${showCpuPercentageInteger} -ge 100 ] ; then + showCpuPercentageBar="====================" +fi + +# Show results +if [ "$1" == "-p" ]; then + echo ${showCpuPercentage}% +elif [ "$1" == "-b" ]; then + echo ${showCpuPercentageBar} +else + echo "" + echo " cpuinfo v$VERSION" + echo " ------------" + echo "" + echo " CpuPercentage Use:" + echo " ${showCpuPercentageBar} ${showCpuPercentage}%" + echo "" + echo " Available commands:" + echo "" + echo " cpuinfo.sh -p | Show CpuPercentage" + echo " cpuinfo.sh -b | Show CpuPercentage Bar" + echo "" + echo " Note: Conky require 'maximum_width = 240'" + echo "" +fi diff --git a/.config/i3blocks/weather/forecast.xml b/.config/i3blocks/weather/forecast.xml index 80ddc3b..285fe0c 100644 --- a/.config/i3blocks/weather/forecast.xml +++ b/.config/i3blocks/weather/forecast.xml @@ -28,391 +28,391 @@ link to the specified URL.--> - 2021-11-13T22:03:49 - 2021-11-14T04:03:49 + 2021-11-14T22:18:12 + 2021-11-15T04:18:12 - + - - - - -