#! /bin/bash
# ____ ____ _ _
# / ___| | _ \ | | | |
# | | | |_) | | | | |
# | |___ | __/ | |_| |
# \____| |_| \___/
#
#written by Christos Angelopoulos,2021
TT="$(echo "$(head -5 /proc/stat)";sleep 0.5 && echo "$(head -5 /proc/stat)")"
MM="$(echo "DISK : "$(df |grep /dev/sda2|awk '{print $5}'))"
R0="$(echo "RAM :"$(free -h|grep "Mem"|awk '{print $3}'))"
R="$(echo "Occupied RAM: "$(free -h|grep "Mem"|awk '{print $3}'))"
S="$(sensors|tail -5|sed 's/ / /g'|sed 's/°C.*$//g')"
RS="$R0
────────────
$S"
#TOTALCPU="$(echo "$TT"|grep 'cpu '| awk -v RS="" '{printf "%.3f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -3)"
TOTALCPU="$(echo "$TT"|grep 'cpu '| awk -v RS="" '{printf "%.4f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -4)"
CPU0="$(echo "$TT"|grep 'cpu0'| awk -v RS="" '{printf "%.0f\n", ($13-$2+$15-$4)*10/($13-$2+$15-$4+$16-$5)}')"
CPU1="$(echo "$TT"|grep 'cpu1'| awk -v RS="" '{printf "%.0f\n", ($13-$2+$15-$4)*10/($13-$2+$15-$4+$16-$5)}')"
CPU2="$(echo "$TT"|grep 'cpu2'| awk -v RS="" '{printf "%.0f\n", ($13-$2+$15-$4)*10/($13-$2+$15-$4+$16-$5)}')"
CPU3="$(echo "$TT"|grep 'cpu3'| awk -v RS="" '{printf "%.0f\n", ($13-$2+$15-$4)*10/($13-$2+$15-$4+$16-$5)}')"
CPU0X="$(echo "$TT"|grep 'cpu0'| awk -v RS="" '{printf "%.3f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -4)"%
CPU1X="$(echo "$TT"|grep 'cpu1'| awk -v RS="" '{printf "%.3f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -4)"%
CPU2X="$(echo "$TT"|grep 'cpu2'| awk -v RS="" '{printf "%.3f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -4)"%
CPU3X="$(echo "$TT"|grep 'cpu3'| awk -v RS="" '{printf "%.3f\n", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'|cut -b -4)"%
if [ $CPU0 -gt 9 ]
then
CPU0=9
fi
if [ $CPU1 -gt 9 ]
then
CPU1=9
fi
if [ $CPU2 -gt 9 ]
then
CPU2=9
fi
if [ $CPU3 -gt 9 ]
then
CPU3=9
fi
#loop to decide which CPU0 levels are on
i=0
while [ $i -lt 9 ]
do
if [ $i -lt $CPU0 ]
then
BAR_0_[$i]="███████_"
else
BAR_0_[$i]=" "
fi
((i++))
done
#loop to decide which CPU1 levels are on
i=0
while [ $i -lt 9 ]
do
if [ $i -lt $CPU1 ]
then
BAR_1_[$i]="███████_"
else
BAR_1_[$i]=" "
fi
((i++))
done
#loop to decide which CPU2 levels are on
i=0
while [ $i -lt 9 ]
do
if [ $i -lt $CPU2 ]
then
BAR_2_[$i]="███████_"
else
BAR_2_[$i]=" "
fi
((i++))
done
#loop to decide which CPU3 levels are on
i=0
while [ $i -lt 9 ]
do
if [ $i -lt $CPU3 ]
then
BAR_3_[$i]="███████"
else
BAR_3_[$i]=" "
fi
((i++))
done
xml=`cat <<EOF
<xml>
<appsettings>
<tooltip>
$MM
────────────
$RS
────────────
cpu0: $CPU0X
cpu1: $CPU1X
cpu2: $CPU2X
cpu3: $CPU3X</tooltip>
<clickaction>gnome-system-monitor</clickaction>
</appsettings>
<item>
<type>box</type>
<attr>
<vertical>0</vertical>
<xalign>1</xalign>
</attr>
<item>
<type>text</type>
<value>$TOTALCPU% </value>
<attr>
<style>font-size: 10pt;font-weight: bold;color: pink</style>
</attr>
</item>
<item>
<type>box</type>
<attr>
<vertical>1</vertical>
<xalign>0</xalign>
<yalign>2</yalign>
<style>padding: 0px</style>
</attr>
<item>
<type>text</type>
<value>${BAR_0_[9]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[8]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[7]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[6]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[5]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[4]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[3]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[2]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[1]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_0_[0]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>███████_</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
</item>
<item>
<type>box</type>
<attr>
<vertical>1</vertical>
<xalign>0</xalign>
<yalign>2</yalign>
<style>padding: 0px</style>
</attr>
<item>
<type>text</type>
<value>${BAR_1_[9]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[8]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[7]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[6]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[5]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[4]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[3]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[2]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[1]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_1_[0]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>███████_</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
</item>
<item>
<type>box</type>
<attr>
<vertical>1</vertical>
<xalign>0</xalign>
<yalign>2</yalign>
<style>padding: 0px</style>
</attr>
<item>
<type>text</type>
<value>${BAR_2_[9]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[8]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[7]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[6]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[5]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[4]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[3]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[2]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[1]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_2_[0]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>███████_</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
</item>
<item>
<type>box</type>
<attr>
<vertical>1</vertical>
<xalign>0</xalign>
<yalign>2</yalign>
<style>padding: 0px</style>
</attr>
<item>
<type>text</type>
<value>${BAR_3_[9]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[8]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[7]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[6]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[5]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[4]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[3]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[2]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[1]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>${BAR_3_[0]}</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
<item>
<type>text</type>
<value>███████</value>
<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color: pink;padding: 0px</style></attr>
</item>
</item>
</item>
</xml>
EOF
`
echo "$xml"
No comments:
Post a Comment