#!/bin/bash # pipeSysInfo # call from .config/openbox/menu.xml like #
# or from cli: pypeSysinfo # required awk, bc if [[ "$1" == "pipe" ]] then pipe="true" fi awk_round () { awk 'BEGIN{printf "%."'$1'"f\n", "'$2'"}' } # cpu usage in percents tmp=$(ps -A -o pcpu | tail -n+2 | paste -sd+ | bc) cpu=$(awk_round 0 "$tmp") # mem usage 245M/15G # https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load read -r memslash mem <<< $(free -m | awk 'NR==2{printf "%s/%sM %.0f%%", $3,$2,$3*100/$2 }') mem="${mem//%}" # /home disk usage in percents and free space in Gb (32% used, 65G free) read -r _ _ _ availdisk usedisk _ <<< $(df -h ~ | tail -1) usedisk="${usedisk//%}" ## upload/download speed (this needs a delay to get the delta calculus, so script will lag a bit) #awk '{if(l1){print ($2-l1)/1024"kB/s",($10-l2)/1024"kB/s"} else{l1=$2; l2=$10;}}' <(tail -1 /proc/net/dev) <(sleep 1; tail -1 /proc/net/dev # ugly stuff ahead # disabled for now #read -r download upload <<< $(awk '{if(l1){print ($2-l1)/1024,($10-l2)/1024} else{l1=$2; l2=$10;}}' <(grep enp10 /proc/net/dev) <(sleep 1; grep enp10 /proc/net/dev)) #download=$(awk_round 0 "$download") #upload=$(awk_round 0 "$upload") # host name, distroname rel=$(lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om) kernel=$(uname -r) distro="$HOSTNAME @ $rel" # uptime and date #read -r _ _ uptime _ _ _ _ _ <<< $(uptime) uptime=$(uptime -p) date=$(date) if [[ "$pipe" == "true" ]] then # pipe display cat << EOFMENU