Monday, September 6, 2021

LINUX MINT CINNAMON CPU USAGE APPLET with BARS

#! /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"

LINUX MINT CINNAMON NETWORK MONITOR APPLET

 The following script in bash, is a cinnamon panel applet for Linux Mint, that provides network monitoring (upload download speed , and bars).

1.Copy the following code

2.Paste it to an empty file

3.Save it in whichever directory you like as network.sh

4.Make this file executable with the following command in terminal(open the terminal in the same directory):

chmod +x network.sh

5.Then make sure you download the CommandRunner Applet in cinnamon panel:

  • Right click on the panel you want to present the network monitor
  • Select Applets
  • Select Download tab, select CommandRunner and download it
  • Back on the Manage tab, press the CommandRunner Configure button.
  •  In the Command field, put : /directory/of/network.sh
  • In the Run Interval field, put: 1 second
  • Hit Apply

6.You are good to go






#! /bin/bash

#  _   _          _                               _    

# | \ | |   ___  | |_  __      __   ___    _ __  | | __

# |  \| |  / _ \ | __| \ \ /\ / /  / _ \  | '__| | |/ /

# | |\  | |  __/ | |_   \ V  V /  | (_) | | |    |   < 

# |_| \_|  \___|  \__|   \_/\_/    \___/  |_|    |_|\_\

#   written by Christos Angelopoulos

NET="$(ifstat -SAnq 0.2 1)"

INTERFACE="$(echo "$NET"|head -1|sed 's/      / /')"

UP="$(echo "$NET" | tail -1|awk '{print $3}'|sed 's/\..*$//')"

DOWN="$(echo "$NET" | tail -1|awk '{print $2}'|sed 's/\..*$//')"

BUP=$(( $UP/12 ))

BDOWN=$(( $DOWN/80 ))

if [ $BDOWN -gt 9 ];then BDOWN=9;fi

if [ $BUP -gt 9 ];then BUP=9;fi

mes1="∇ "$(echo "$DOWN")" kB "

mes3="∆ "$(echo "$UP")" kB "


#loop to decide which download levels are on 

i=0

while [ $i -lt 9 ]

do

 if [ $i -lt $BDOWN ]

 then

  BAR_0_[$i]="███████_"

 else

  BAR_0_[$i]="        "

fi

((i++))

done

#loop to decide which upload levels are on 

i=0

while [ $i -lt 9 ]

do

 if [ $i -lt $BUP ]

 then

  BAR_1_[$i]="_███████"

 else

  BAR_1_[$i]="        "

fi

((i++))

done



xml=`cat <<EOF

<xml>

<appsettings>

<tooltip>     Interface :$INTERFACE

Download : $DOWN kB/s

Upload :      $UP kB/s</tooltip>

<clickaction>cinnamon-settings network</clickaction>

</appsettings>

<item>

<type>box</type>

<attr>

<vertical>1</vertical>

</attr>


<item>

<type>box</type>

<attr>

<vertical>0</vertical>

<xalign>0</xalign>

</attr>

<item>

<type>box</type>

<attr>

<vertical>1</vertical>

<xalign>0</xalign>

</attr>

<item>

<type>text</type>

<value>$mes1</value> 

<attr><xalign>0</xalign><style>padding: 0px;font-size: 9pt;font-weight: bold;color:orange</style></attr>

</item>


<item>

<type>text</type>

<value>$mes3</value> 

<attr><xalign>0</xalign><style>padding: 0px;font-size: 9pt;font-weight: bold;color:rgb(95,215,175)</style></attr>

</item>

</item>

</item>

<item>

<type>text</type>

<value>XXXXXXXXXXXXXXXXΧΧΧXXXXXXXXX</value> 

<attr><xalign>0</xalign><yalign>2</yalign><style>font-size: 2pt;color:rgb(88,88,88)</style></attr>

</item>      

</item>

<item>

<type>box</type>

<attr>

<vertical>1</vertical>

<xalign>0</xalign>

<yalign>0</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:orange;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:orange;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:orange;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:orange;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:orange;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:orange;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:orange;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:orange;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:orange;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:orange;padding: 0px</style></attr>

</item>

<item>

<type>text</type>

<value>███████_</value> 

<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:orange;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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);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:rgb(95,215,175);padding: 0px</style></attr>

</item>

<item>

<item>

<type>text</type>

<value>${BAR_1_[0]}</value> 

<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:rgb(95,215,175);padding: 0px</style></attr>

</item>

<type>text</type>

<value>_███████</value> 

<attr><xalign>0</xalign><style>font-size: 1pt;font-weight: bold;color:rgb(95,215,175);padding: 0px</style></attr>

</item>


</item>


</xml>


EOF

`

echo "$xml"



LINUX MINT CINNAMON CPU USAGE APPLET with BARS

#! /bin/bash #   ____   ____    _   _  #  / ___| |  _ \  | | | | # | |     | |_) | | | | | # | |___  |  __/  | |_| | #  \____| |_|      \___...