From bc13d406e284d5c843a2744c9edc73e522cc0189 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Fri, 25 Dec 2020 20:28:58 +0530 Subject: added a bar for hlwm --- herbstluftwm/bar/functions/sysinfo | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 herbstluftwm/bar/functions/sysinfo (limited to 'herbstluftwm/bar/functions/sysinfo') diff --git a/herbstluftwm/bar/functions/sysinfo b/herbstluftwm/bar/functions/sysinfo new file mode 100755 index 00000000..a377c600 --- /dev/null +++ b/herbstluftwm/bar/functions/sysinfo @@ -0,0 +1,48 @@ +#!/bin/zsh + +date_time() { + datetime=$(date +"%d %b(%A) %H:%M") + echo $datetime +} + +cpu_load() { + 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%" +} + +cpu_temp() { + CEL=$'\xc2\xb0C' + temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp ) + temp=`expr $temp / 1000` + echo "TEMP: " $temp$CEL +} + +root_usage() { + root=$(df -h / | awk 'NR==2 {print $4 "/" $2}') + echo "ROOT: "$root +} + +home_usage() { + home=$(df -h /home | awk 'NR==2 {print $4 "/" $2}') + echo "HOME: "$home +} + +mem_usage() { + mem=$(free -m | grep Mem: | awk '{print$3 / $2 * 100}') + printf "MEM: %.0f %%" $mem +} + +while :; do + echo $(date_time) > /home/zt/.cache/lemon/clock + echo $(cpu_load) > /home/zt/.cache/lemon/cpu_load + echo $(cpu_temp) > /home/zt/.cache/lemon/cpu_temp + echo $(root_usage) > /home/zt/.cache/lemon/disk_root + echo $(home_usage) > /home/zt/.cache/lemon/disk_home + echo $(mem_usage) > /home/zt/.cache/lemon/mem + sleep 3 +done -- cgit v1.2.3