From f4d2df3865ac1312157152b47c43c78de24d1ceb Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 6 Jan 2012 11:09:03 +0100 Subject: [PATCH] PANEL: Tronify and minify Tronify some of the colors of the panel and minimize it. The panel is now 1px high and shows only tags and if any of my mailboxes have mail in them. --- .config/herbstluftwm/panel.sh | 109 +++++++++++++++++----------------- 1 file changed, 55 insertions(+), 54 deletions(-) diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh index 34f1487..448a0c6 100755 --- a/.config/herbstluftwm/panel.sh +++ b/.config/herbstluftwm/panel.sh @@ -1,6 +1,7 @@ #!/bin/bash monitor=${1:-0} +monitor2=1 geometry=( $(herbstclient monitor_rect "$monitor") ) if [ -z "$geometry" ] ;then echo "Invalid monitor $monitor" @@ -10,70 +11,75 @@ fi x=${geometry[0]} y=${geometry[1]} width=${geometry[2]} -height=16 +height=1 +tag_width=40 font="-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*" -fgcolor='#eeeeec' -bgcolor='#252a2b' -hintcolor="#0c191c" + +selcolor='#24c6e0' +locolor='#15abc3' +bgcolor='#000000' +hicolor="#808080" +urcolor="#e0c625" function uniq_linebuffered() { awk '$0 != l { print ; l=$0 ; fflush(); }' "$@" } -herbstclient pad $monitor $height +herbstclient pad $monitor $(expr $height - 4) -5 -5 -5 +herbstclient pad $monitor2 -5 -5 -5 -5 { - # events: - #mpc idleloop player & - while true ; do - date +'date ^fg($fgcolor)%H:%M^fg(#909090), %Y-%m-^fg($fgcolor)%d' - sleep 1 || break - done > >(uniq_linebuffered) & childpid=$! herbstclient --idle kill $childpid } 2> /dev/null | { TAGS=( $(herbstclient tag_status $monitor) ) - date="" + TAGS2=( $(herbstclient tag_status $monitor2) ) while true ; do - bordercolor="#26221C" - separator="^fg(#141414)^ro(1x$height)^fg()" + separator="^fg($bgcolor)^ro(1x$height)^fg()" # draw tags echo -n "$separator" for i in "${TAGS[@]}" ; do - case ${i:0:1} in - '#') - echo -n "^bg(#0c191c)^fg(#eeeeec)" - ;; - '+') - echo -n "^bg(#2e3436)^fg(#555753)" - ;; - ':') - echo -n "^bg(#2e3436)^fg($fgcolor)" - ;; - '!') - echo -n "^bg(#a40000)^fg(#edd400)" - ;; - *) - echo -n "^bg()^fg()" - ;; - esac - echo -n " ${i:1} " + if [[ "${TAGS2[@]}" == *"#${i:1}"* ]]; then + echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()" + elif [[ "${TAGS2[@]}" == *"+${i:1}"* ]]; then + echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()" + else + case ${i:0:1} in + '#') + echo -n "^fg($selcolor)^ro(${tag_width}x$height)^fg()" + ;; + '+') + echo -n "^fg($locolor)^ro(${tag_width}x$height)^fg()" + ;; + ':') + echo -n "^fg($hicolor)^ro(${tag_width}x$height)^fg()" + ;; + '!') + echo -n "^fg($urcolor)^ro(${tag_width}x$height)^fg()" + ;; + *) + echo -n "^bg()^fg($bgcolor)^ro(${tag_width}x$height)^fg()" + ;; + esac + fi echo -n "$separator" done - echo -n "^bg()^p(_CENTER)" - # small adjustments - nfmail=`ls ~/documents/mail/ninthfloor/INBOX/new/ | wc -l` - gmail=`ls ~/documents/mail/gmail/INBOX/new/ | wc -l` - archmail=`ls ~/documents/mail/arch/INBOX/new/ | wc -l` - aethonmail=`ls ~/documents/mail/aethon/INBOX/new/ | wc -l` - todoline=`cat ~/.config/herbstluftwm/todo` - todoline_sha1=`echo $todoline | sha1sum` - todoline_color=${todoline_sha1:0:6} - right="^fg(#$todoline_color)$todoline^fg() $separator 9f: $nfmail $separator gmail: $gmail $separator arch: $archmail $separator aethon: $aethonmail $separator^bg($hintcolor) $date $separator" - right_text_only=$(echo -n "$right"|sed 's.\^[^(]*([^)]*)..g') - # get width of right aligned text.. and add some space.. - width=$(textwidth "$font" "$right_text_only ") - echo -n "^p(_RIGHT)^p(-$width)$right" + + mailboxes=(ninthfloor gmail arch aethon ryuslash.org) + echo -n "^p(_RIGHT)^p(-$(expr $tag_width \* ${#mailboxes[@]} + 5))" + for j in "${mailboxes[@]}"; do + mailfile="$HOME/documents/mail/$j/INBOX/new/" + mailcnt=$(ls $mailfile | wc -l) + + if [ $mailcnt -gt 0 ]; then + mailsha1=$(echo $j | sha1sum) + mailcolor="#${mailsha1:0:6}" + else + mailcolor=$bgcolor + fi + + echo -n "^fg($mailcolor)^ro(${tag_width}x$height)^fg()$separator" + done echo # wait for next event read line || break @@ -83,17 +89,12 @@ herbstclient pad $monitor $height tag*) #echo "reseting tags" >&2 TAGS=( $(herbstclient tag_status $monitor) ) - ;; - date) - #echo "reseting date" >&2 - date="${cmd[@]:1}" + TAGS2=( $(herbstclient tag_status $monitor2) ) ;; quit_panel) exit ;; - #player) - # ;; esac - done + done } 2> /dev/null | dzen2 -w $width -x $x -y $y -fn "$font" -h $height \ - -ta l -bg "$bgcolor" -fg "$fgcolor" + -ta l -bg "$bgcolor"