diff options
author | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-12-25 20:28:58 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2020-12-25 20:28:58 +0530 |
commit | bc13d406e284d5c843a2744c9edc73e522cc0189 (patch) | |
tree | f41b13bd175a682ee072d4b81afacc4ce9d7ba9f /herbstluftwm/bar/functions/sysinfo | |
parent | 2b1696744fa839f9adf05337e810472c299e3652 (diff) |
added a bar for hlwm
Diffstat (limited to 'herbstluftwm/bar/functions/sysinfo')
-rwxr-xr-x | herbstluftwm/bar/functions/sysinfo | 48 |
1 files changed, 48 insertions, 0 deletions
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 |