All pastes #639551 Raw Edit

Untitled

public text v1 · immutable
#639551 ·published 2007-07-30 17:32 UTC
rendered paste body
#!/bin/sh

MAIL=""
DATE=""
LOAD=""
BAT=""
setmail() {
  MAIL=""
  cd ~/mail
  for i in *; do 
    if [ -d $i/new ]; then 
      n=`ls $i/new/ | wc -l`
      if [[ $n > 0 ]]; then
        MAIL="$MAIL$i=$n, "
      fi
    fi
  done
}

setdate() {
  DATE=$(date +"%Y-%m-%d %H:%M")
}

setload() {
  LOAD=$(uptime | sed 's/.*,//')
}

setbat() {
full=$(grep "full capacity" /proc/acpi/battery/C1B5/info | tr -s ' ' |cut -d' ' -f4)
current=$(grep "remaining capacity" /proc/acpi/battery/C1B5/state | tr -s ' ' |cut -d' ' -f3)
BAT=$(echo "$current*100/$full" | bc)
}

while true
do
  setmail
  setdate
  setload
  setbat
  echo "$MAIL $DATE $LOAD $BAT%" > ~/.dwm-status
  sleep 30
done