Created
January 6, 2012 18:45
-
-
Save bollovan/1571863 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: ~/.bin/dwm-status | |
# description: status script for dwm's statusbar | |
# note: the weird symbols are for the custom-made icons from the font | |
#!/bin/zsh | |
date_format="%H:%M, %a %d %b %Y" | |
internet_checker() { # {{{ | |
if host google.com &> /dev/null | |
then return 0 | |
else return 1 | |
fi | |
} # }}} | |
gmail_website_checker() { # {{{ | |
if host mail.google.com &> /dev/null | |
then return 0 | |
else return 1 | |
fi | |
} # }}} | |
gmail_notify() { # {{{ | |
if internet_checker ; then | |
. $HOME/backup/gmail # Where $username and $password are set | |
curl -s "https://${username}:${password}@mail.google.com/mail/feed/atom" -o ${HOME}/.mailcache | |
fullcount=$(awk -F '</?fullcount>' 'NF>1{print $2}' ${HOME}/.mailcache) | |
#if (( "$fullcount" == 0 )) ; then | |
#echo -e " õ \x06ý \x07no new emails\x01" | |
#elif (( "$fullcount" == 1 )) ; then | |
#echo -e " õ \x05ý 1\x07 new email\x01" | |
#else | |
#echo -e " õ \x05ý \x05${fullcount}\x01 \x07new emails\x01" | |
#fi | |
case "$fullcount" in | |
0) echo -e " õ \x07ý \x08no new emails\x01" ;; | |
1) echo -e " õ \x06ý 1\x08 new email\x01" ;; | |
*) echo -e " õ \x06ý \x06${fullcount}\x01 \x08new emails\x01" ;; | |
esac | |
fi | |
} # }}} | |
date_get() { # {{{ | |
date_command=$(date +"$date_format") | |
echo -e "õ \x05ù \x04${date_command}\x01" | |
} # }}} | |
mpd_check() { # {{{ | |
if mpc -q && [[ $(mpc | wc -l) != 1 ]] | |
then return 0 | |
else return 1 | |
fi | |
} # }}} | |
check_mpd_pause() { # {{{ | |
if mpc | grep -oq '^\[paused\]' ; then | |
echo " ø" | |
fi | |
} # }}} | |
mpd_details() { # {{{ | |
if mpd_check ; then | |
echo -e "\x08î\x07 $(mpc -f '%artist% - %title% (%album%)' | head -1)\x01\x04$(check_mpd_pause)\x02 $(mpc | grep -o '[0-9]\+:[0-9]\{2\}/[0-9]\+:[0-9]\{2\}')\x01" | |
fi | |
} # }}} | |
# main | |
xsetroot -name "$(mpd_details)$(gmail_notify) $(date_get)" | |
# vim: ft=sh: fdm=marker: et: ts=4: sw=4: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment