All pastes #838092 Raw Edit

Stuff

public shellscript v1 · immutable
#838092 ·published 2007-12-30 03:07 UTC
rendered paste body
#!/bin/sh# SIMMPLE DWM-STATUSBAR.# THIS FUNCTIONS DRAWS THE BARfunction draw_bar () {        case $1 in                "0")                        echo "[----------]"                        ;;                      "1")                        echo "[#---------]"                        ;;                "2")                        echo "[##--------]"                        ;;                "3")                        echo "[###-------]"                        ;;                "4")                         echo "[####------]"                        ;;                "5")                        echo "[#####-----]"                        ;;                "6")                        echo "[######----]"                        ;;                "7")                        echo "[#######---]"                        ;;                "8")                        echo "[########--]"                        ;;                "9")                        echo "[#########-]"                        ;;                *)                        echo "[##########]"                        ;;        esac}function status () {        upd="5"         # UPDATE INTERVAL        sep=" ¤ "       # SEPARATOR        fst=${sep: -1}  # FIRST SEPARATOR        lst=${sep:0:1}  # LAST SEPARATOR                # date        date=`date '+%a %b %d %r'`                # uptime        uptime=`cat /proc/uptime |awk '{ print $1 }' |sed 's/\..*//'`        uptime=`echo "((${uptime}/60)/60)"| bc -l |sed 's/\..*//'`        uptime="upt: ${uptime}H"                # mpd        mpd="mpd: `mpc |head -n1`"        check=`mpc |head -n1|awk '{ print $1 }'`        if [ "${check}" = "volume:" ]; then                 mpd='mpd: stopped'         fi        # Memory        mem_tot=`free -m |grep Mem: |awk '{ print $2 }'`        mem_use=`free -m |grep 'buffers/cache' |awk '{ print $3 }'`        mem_per=`echo "${mem_use}/${mem_tot}" | bc -l |sed 's/.//'`        mem_bars=${mem_per:0:1}        mem_str="mem: `draw_bar ${mem_bars}`"                # Diskspace        disk_str=""        disks=`df -h |awk '{ print $6 }'|grep -vP 'boot|none|shm|Mounted'`        for disk in ${disks}; do                disk_per="`df -h |grep -P ${disk}\$ |awk '{ print $5 }'`"                disk_str="${disk_str}${disk}: `draw_bar ${disk_per:0:1}`${sep}"        done                # CPU        stat="0.0 "        for dat in `ps axu | awk '{ print $3 }' |sed 's/%CPU//'`; do                        stat="${stat}+ ${dat} "        done        stat=`echo ${stat} |bc -l`        cpu_scaling="cpu: `draw_bar ${stat:0:1}`"        # PRINT        echo "${fst}${mem_str}${sep}${cpu_scaling}${sep}${disk_str}${mpd}${sep}${uptime}${sep}${date}${lst}"|tr "[:upper:]" "[:lower:]"}while true; do        status        sleep ${upd}done