scripts

Utility script that make my life slightly easier
Log | Files | Refs | README | LICENSE

commit 861777064dcc18d669db5f32e06d37f8657bf7b1
parent 778bcdad73546cb33644b6e2c16f78e909201acc
Author: M. Yamanaka <myamanaka@live.com>
Date:   Mon, 11 Jan 2021 21:36:46 -0500

resource monitor script added

Diffstat:
Aresmon.sh | 80+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+), 0 deletions(-)

diff --git a/resmon.sh b/resmon.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +## System Resource Monitor Script +## "resmon.sh" +## M. Yamanaka +## email: myamanaka@live.com +## website: csmyamanaka.com +## license: MIT (See included "LICENSE" file for detais) + +#Prints information of interest regarding a user's system + + +## +## Information +## + +VOLTEXT="volume" +VOLSTAT=$(pactl list sinks | grep "Volume: front-left:" | awk '{print $5}') + +MEMTEXT="RAM" +MEMSTAT=$(free -h | grep "Mem:" | awk '{print $3" / "$2}') + +BATTEXT="battery" +BATINFO=/sys/class/power_supply/BAT1 +BATSTAT="$(( $(cat $BATINFO/charge_now)*100/$(cat $BATINFO/charge_full) )) ($(cat $BATINFO/status))" + +CLKTEXT="time" +CLKSTAT=$(date +"%T %Y-%b-%d") + +## +## Print formatting +## + +#print order +#default order is volume, RAM, battery, time +PRTORDER="vrbt" + +DELIM="|" + +#change order according to user input +if [ "$1" != "" ] +then + PRTORDER=$1 +fi + +#return string +PRTSTRING="" + +#keep track of original order +ORGORDER=$PRTORDER + +while [ "$PRTORDER" != "" ] +do + #get the first character + CRTOBJ=$(echo $PRTORDER | cut -b 1) + CRTSTRING="" + case $CRTOBJ in + "v") CRTSTRING="$VOLTEXT: $VOLSTAT" ;; + "t") CRTSTRING="$CLKTEXT: $CLKSTAT" ;; + "b") CRTSTRING="$BATTEXT: $BATSTAT" ;; + "r") CRTSTRING="$MEMTEXT: $MEMSTAT" ;; + *) + echo "bad!" + exit 1 + ;; + esac + + #on first run, don't print the delimiter + if [ "$PRTORDER" = "$ORGORDER" ] + then + PRTSTRING="$CRTSTRING" + else + PRTSTRING="$PRTSTRING $DELIM $CRTSTRING" + fi + + #remove the first character + PRTORDER=$(echo $PRTORDER | sed "s/^.//g") +done + +echo $PRTSTRING

Generated using stagit (https://codemadness.org/stagit.html)