config/polybar/mail.sh

   1 #!/bin/bash
   2 
   3 mkdir -p ~/.cache/polybar
   4 
   5 cache=$_/mail
   6 utime=$(date +%s)
   7 mtime=$(stat -c %Y $cache)
   8 diff=$(($utime - ${mtime:-0}))
   9 
  10 if (( $diff > $1 )); then
  11     echo '?' > $cache
  12     n=$(fetchmail.sh -c | awk '{ n += $1 } END { print n }')
  13     echo $n > $cache
  14 fi
  15 
  16 cat $cache
  17