From 52cf0938f82d20bf192cb7ea989757fb4ede0c7e Mon Sep 17 00:00:00 2001 From: q3aql Date: Fri, 28 Jan 2022 16:28:37 +0100 Subject: [PATCH] Dotfiles config update (2021-01-28) --- .config/i3blocks/cpu/cpu_info.sh | 23 +++++++-- .config/polybar/cpu_info.sh | 23 +++++++-- .config/polybar/cpu_load.sh | 83 ++++++++++++++++++++++++++++++ .config/spectrwm/baraction.sh | 39 +++++++++++--- .config/waybar/scripts/cpu_info.sh | 23 +++++++-- .config/waybar/scripts/cpu_load.sh | 83 ++++++++++++++++++++++++++++++ .vimrc | 2 + 7 files changed, 256 insertions(+), 20 deletions(-) create mode 100755 .config/polybar/cpu_load.sh create mode 100755 .config/waybar/scripts/cpu_load.sh diff --git a/.config/i3blocks/cpu/cpu_info.sh b/.config/i3blocks/cpu/cpu_info.sh index 68b8e9c..d2521ba 100755 --- a/.config/i3blocks/cpu/cpu_info.sh +++ b/.config/i3blocks/cpu/cpu_info.sh @@ -1,5 +1,20 @@ #!/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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) -echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + +check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) +if [ -z "${check_sensor}" ] ; then + check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) + if [ -z "${check_sensor}" ] ; then + CPU_USAGE=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE" | awk '{ printf(" CPU:%6s \n"), $1, $2 }' + else + TEMP=$(sensors | grep 'Package id 0:\|Tctl' | 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + fi +else + 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' +fi diff --git a/.config/polybar/cpu_info.sh b/.config/polybar/cpu_info.sh index 68b8e9c..3c4321e 100755 --- a/.config/polybar/cpu_info.sh +++ b/.config/polybar/cpu_info.sh @@ -1,5 +1,20 @@ #!/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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) -echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + +check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) +if [ -z "${check_sensor}" ] ; then + check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) + if [ -z "${check_sensor}" ] ; then + CPU_USAGE=$(~/.config/polybar/cpu_load.sh -p) + echo "$CPU_USAGE" | awk '{ printf(" CPU:%6s \n"), $1, $2 }' + else + TEMP=$(sensors | grep 'Package id 0:\|Tctl' | 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + fi +else + 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' +fi diff --git a/.config/polybar/cpu_load.sh b/.config/polybar/cpu_load.sh new file mode 100755 index 0000000..57fc7e5 --- /dev/null +++ b/.config/polybar/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/spectrwm/baraction.sh b/.config/spectrwm/baraction.sh index 7902080..a84d740 100755 --- a/.config/spectrwm/baraction.sh +++ b/.config/spectrwm/baraction.sh @@ -87,14 +87,37 @@ kernel() { ## CPU cpu() { - TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) - read cpu a b c previdle rest < /proc/stat - prevtotal=$((a+b+c+previdle)) - sleep 0.5 - read cpu a b c idle rest < /proc/stat - total=$((a+b+c+idle)) - cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) - echo -e "CPU: $cpu% @ ${TEMP}" + check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) + if [ -z "${check_sensor}" ] ; then + check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) + if [ -z "${check_sensor}" ] ; then + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e "CPU: $cpu%" + else + TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e "CPU: $cpu% @ ${TEMP}" + fi + else + TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e "CPU: $cpu% @ ${TEMP}" + fi } ## VOLUME diff --git a/.config/waybar/scripts/cpu_info.sh b/.config/waybar/scripts/cpu_info.sh index 68b8e9c..a1f5a77 100755 --- a/.config/waybar/scripts/cpu_info.sh +++ b/.config/waybar/scripts/cpu_info.sh @@ -1,5 +1,20 @@ #!/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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) -echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + +check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) +if [ -z "${check_sensor}" ] ; then + check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) + if [ -z "${check_sensor}" ] ; then + CPU_USAGE=$(~/.config/waybar/scripts/cpu_load.sh -p) + echo "$CPU_USAGE" | awk '{ printf(" CPU:%6s \n"), $1, $2 }' + else + TEMP=$(sensors | grep 'Package id 0:\|Tctl' | 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' + fi +else + 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=$(~/.config/i3blocks/cpu/cpu_load.sh -p) + echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }' +fi diff --git a/.config/waybar/scripts/cpu_load.sh b/.config/waybar/scripts/cpu_load.sh new file mode 100755 index 0000000..57fc7e5 --- /dev/null +++ b/.config/waybar/scripts/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/.vimrc b/.vimrc index 2e38552..e66793a 100755 --- a/.vimrc +++ b/.vimrc @@ -18,6 +18,8 @@ let $NVIM_TUI_ENABLE_TRUE_COLOR=1 " Hide menu/toolbar of GVIM ":set guioptions -=m :set guioptions -=T +:set guioptions -=r +:set guioptions -=L " Helps force plug-ins to load correctly when it is turned back on below. filetype off