blob: 0d2b8e4966d7a8ee3f2dac75038fda19389b997c (
plain) (
blame)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#!/bin/sh
typeset -A DISKS
###
# Config
###
DATE_FORMAT="%a %d %b, %Y"
TIME_ZONES=("America/Toronto" "UTC")
DISKS=(home /home root /)
SEPERATOR=' ^fg(#86AA3F)^c(3)^fg() '
BAR_BG='#7DA926'
BAR_FG='#B9D56E'
BAR_HH=6
BAR_HW=40
BAR_VH=12
BAR_VW=3
BAR_ARGS="-bg $BAR_BG -fg $BAR_FG -w $BAR_HW -h $BAR_HH"
ICON_DIR="$HOME/.dzen/icons/"
NETWORK_INTERFACE=eth0
NET_DOWN_MAX=55
NET_UP_MAX=14
MAILDIR=~/.maildb/GMAIL/
GLOBALIVAL=1m
DATEIVAL=60
TIMEIVAL=1
DISKIVAL=1
#CPUTEMPIVAL=5
#CPUIVAL=1
#NPIVAL=3
NETIVAL=1
###
# Functions
###
_date()
{
date +${DATE_FORMAT}
}
_time()
{
local zone
print_space=0
for zone in $TIME_ZONES; do
[[ $print_space -eq 1 ]] && print -n " "
print -n "${zone:t}: $(TZ=$zone date '+%H:%M')"
print_space=1
done
}
#
# Format: label1 mountpoint1 label2 mountpoint2 ... labelN mountpointN
# Copied and modified from Rob
get_disk_usage() {
local rstr; local tstr; local i; local sep
for i in ${(k)DISKS}; do
tstr=$(print `df -h $DISKS[$i]|sed -ne 's/^.* \([0-9]*\)% .*/\1/p'` 100 | \
dzen2-gdbar -h $BAR_HH -w $BAR_HW -fg $BAR_FG -bg $BAR_BG -l "${i}" -nonl | \
sed 's/[0-9]\+%//g;s/ / /g')
if [ ! -z "$rstr" ]; then
sep=${SEPERATOR}
fi
rstr="${rstr}${sep}${tstr}"
done
print -n $rstr
}
# Requires mesure
get_net_rates() {
local up; local down
up=`mesure -K -l -c 3 -t -o $NETWORK_INTERFACE`
down=`mesure -K -l -c 3 -t -i $NETWORK_INTERFACE`
echo "$down $up"
}
#cpu_temp()
#{
# print -n ${(@)$(</proc/acpi/thermal_zone/THRM/temperature)[2,3]}
#}
#
#np()
#{
# #MAXPOS="100"
# CAPTION="^i(${ICON_DIR}/musicS.xbm)"
# #POS=`mpc | sed -ne 's/^.*(\([0-9]*\)%).*$/\1/p'`
# #POSM="$POS $MAXPOS"
# print -n "$CAPTION "
# mpc | head -n1 | tr -d '\n'
# #echo "$POSM" | gdbar -h 7 -w 50 -fg $BAR_FG -bg $BAR_BG
#}
#
#cpu()
#{
# gcpubar -c 2 -bg $BAR_BG -fg $BAR_FG -w $BAR_HW -h $BAR_HH | tail -n1 | tr -d '\n'
#}
has_new_mail() {
find ${MAILDIR}/*/new -not -type d | wc -l
}
DATEI=0
TIMEI=0
DISKI=0
#NPI=0
#CPUTEMPI=0
#CPUI=0
NETI=0
date=$(_date)
times=$(_time)
disk_usage=$(get_disk_usage)
#now_playing=$(np)
#temp=$(cpu_temp)
#cpumeter=$(cpu)
net_rates=( `get_net_rates` )
while true; do
[[ $DATEI -ge $DATEIVAL ]] && date=$(_date) && DATEI=0
[[ $TIMEI -ge $TIMEIVAL ]] && times=$(_time) && TIMEI=0
[[ $DISKI -ge $DISKIVAL ]] && disk_usage=$(get_disk_usage) && DISKI=0
#[[ $NPI -ge $NPIVAL ]] && now_playing=$(np) && NPI=0
#[[ $CPUI -ge $CPUIVAL ]] && cpumeter=$(cpu) && CPUI=0
#[[ $CPUTEMPI -ge $CPUTEMPIVAL ]] && temp=$(cpu_temp) && CPUTEMPI=0
[[ $NETI -ge $NETIVAL ]] && net_rates=( `get_net_rates` ) && NETI=0
# Disk usage
echo -n "${disk_usage}${SEPERATOR}"
# Network
echo $net_rates[1] | dzen2-gdbar -nonl -s v -w $BAR_VW -h $BAR_VH -min 0 \
-max $NET_DOWN_MAX -fg $BAR_FG -bg $BAR_BG
echo -n " "
echo $net_rates[2] | dzen2-gdbar -nonl -s v -w $BAR_VW -h $BAR_VH -min 0 \
-max $NET_UP_MAX -fg $BAR_FG -bg $BAR_BG
echo -n "${SEPERATOR}"
# Mail notification
if [ `has_new_mail` -gt 0 ]; then
echo -n "^fg(#73d216)"
fi
echo -n "^i(${ICON_DIR}/mail.xbm)^fg()${SEPERATOR}"
# Time and date
echo -n "${times}${SEPERATOR}"
echo -n "${date}"
echo
DATEI=$(($DATEI+1))
TIMEI=$(($TIMEI+1))
DISKI=$(($DISKI+1))
#NPI=$(($NPI+1))
#CPUI=$(($CPUI+1))
#CPUTEMPI=$(($CPUTEMPI+1))
NETI=$(($NETI+1))
sleep $GLOBALIVAL
done
|