1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/bin/bash
shopt -s expand_aliases; source ~/.bashrc
# ======================================================================================
interval=1
separator=" | "
# --------------------------------------------------------------------------------------
battIval=60
function battUpdate {
if [ `acpi -a | grep -c "on-line"` -eq 1 ]; then
batt="^i(/home/kamil/.dzen/icons/power-ac.xbm)"
if [ `acpi -b | grep -c "Full"` -ne 1 ]; then
batt="$batt "`acpi -b | awk '{print $4}'`
fi
else
batt="^i(/home/kamil/.dzen/icons/power-bat.xbm)"
battValue=`acpi -b | awk '{print $4}'`
battRound=`echo $battValue | sed s/"\(\.[0-9]*\)*%"//g`
if [ "$battRound" -ge 50 ]; then
batt="$batt$battValue"
elif [ "$battRound" -lt 50 ] && [ "$battRound" -ge 25 ]; then
batt="$batt^fg($colFgNormal)$battValue^fg()"
elif [ "$battRound" -lt 25 ] && [ "$battRound" -ge 10 ]; then
batt="$batt^fg($colFgFocus)$battValue^fg()"
else
batt="$batt^fg($colFgUrgent)$battValue^fg()"
fi
fi
}
# --------------------------------------------------------------------------------------
clockIval=60
function clockUpdate {
clock="^fg($colFgNormal)`fuzzytime clock --caps 0`^fg()"
}
# --------------------------------------------------------------------------------------
dateIval=300
function dateUpdate {
date="`date +\"%m.%d.\"`"
}
# --------------------------------------------------------------------------------------
gmailIval=300
function gmailUpdate {
ping www.google.com -c 1 &> /dev/null
if [ $? == 0 ]; then
gmail=`/home/kamil/.dzen/gmail_unread_count.sh`
if [ "$gmail" -gt 0 ]; then
gmail="^fg($colFgFocus)$gmail^fg()"
elif [ "$gmail" -eq 0 ]; then
gmail="^fg($colFgNormal)$gmail^fg()"
else
gmail="problem"
fi
else
gmail="?"
fi
}
# --------------------------------------------------------------------------------------
revDecIval=1
function revDecUpdate {
revDec=`revdectime`
}
# ======================================================================================
battCnt=0; battUpdate
clockCnt=0; clockUpdate
dateCnt=0; dateUpdate
gmailCnt=0; gmail=""
revDecCnt=0; revDecUpdate
while true; do
if [ $battCnt -ge $battIval ]; then battUpdate; battCnt=0; fi
battCnt=$((battCnt+1))
if [ $clockCnt -ge $clockIval ]; then clockUpdate; clockCnt=0; fi
clockCnt=$((clockCnt+1))
if [ $dateCnt -ge $dateIval ]; then dateUpdate; dateCnt=0; fi
dateCnt=$((dateCnt+1))
if [ $gmailCnt -ge $gmailIval ]; then gmailUpdate; gmailCnt=0; fi
gmailCnt=$((gmailCnt+1))
if [ $revDecCnt -ge $revDecIval ]; then revDecUpdate; revDecCnt=0; fi
revDecCnt=$((revDecCnt+1))
echo "${gmail}${separator}${batt}${separator}${date}${separator}${revDec}${separator}${clock}"
sleep $interval
done | dzen2 -bg "$colBgNormal" -fg "$colFgUnimp" -fn "$fontNormal" -ta r -w 720 -x 720 -h 24
|
x
Notes
Minimalistic and comfortable.
dipilibupap said about 13 years ago
I was looking for a dzen script to add to my stumpwm setup. This one is the one :)
Cheers
mahatman2 said about 12 years ago
Nice looking dzen2! However I was wondering what the gmail-checking script was? (the ~/.dzen/gmail_unread_count.sh)