legacy-dotfiles/.config/herbstluftwm/panel.sh
Tom Willemsen f4d2df3865 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.
2012-01-06 11:09:03 +01:00

100 lines
3 KiB
Bash
Executable file

#!/bin/bash
monitor=${1:-0}
monitor2=1
geometry=( $(herbstclient monitor_rect "$monitor") )
if [ -z "$geometry" ] ;then
echo "Invalid monitor $monitor"
exit 1
fi
# geometry has the format: WxH+X+Y
x=${geometry[0]}
y=${geometry[1]}
width=${geometry[2]}
height=1
tag_width=40
font="-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*"
selcolor='#24c6e0'
locolor='#15abc3'
bgcolor='#000000'
hicolor="#808080"
urcolor="#e0c625"
function uniq_linebuffered() {
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
}
herbstclient pad $monitor $(expr $height - 4) -5 -5 -5
herbstclient pad $monitor2 -5 -5 -5 -5
{
childpid=$!
herbstclient --idle
kill $childpid
} 2> /dev/null | {
TAGS=( $(herbstclient tag_status $monitor) )
TAGS2=( $(herbstclient tag_status $monitor2) )
while true ; do
separator="^fg($bgcolor)^ro(1x$height)^fg()"
# draw tags
echo -n "$separator"
for i in "${TAGS[@]}" ; do
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
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
cmd=( $line )
# find out event origin
case "${cmd[0]}" in
tag*)
#echo "reseting tags" >&2
TAGS=( $(herbstclient tag_status $monitor) )
TAGS2=( $(herbstclient tag_status $monitor2) )
;;
quit_panel)
exit
;;
esac
done
} 2> /dev/null | dzen2 -w $width -x $x -y $y -fn "$font" -h $height \
-ta l -bg "$bgcolor"