blob: 738f11f16597d6dc979b8a15b258482e3dc83d02 (
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
|
#!/bin/sh
timeout=1
_sys_memory() {
vmstat | sed -n '$p' | awk '{print $4}'
}
_sys_uptime() {
uptime | sed -re's/^.*up[ ]+//g' -e's/^([^,]*),.*/\1/g' -e's/^([^ ]+)[ ]*(.).*/\1\2/g'
}
wireless_info() {
_if="$1"
printf "WiFi: %s %s %s %s" \
"$_if" \
"$(ifconfig "$_if" | sed -nre 's/^.*nwid ([^ ]+).*$/\1/p')" \
"$(ifconfig "$_if" | sed -nre 's/^.* ([^ ]+dBm) .*$/\1/p')" \
"$(ifconfig "$_if" | sed -nre 's/^.*inet ([^ ]+).*$/\1/p')"
}
eth_info() {
_if="$1"
printf "Eth: %s %s %s" \
"$_if" \
"$(ifconfig "$_if" | sed -nre 's/^.*inet ([^ ]+).*$/\1/p')"
"$(ifconfig "$_if" | grep -oE '[0-9]+baseT')"
}
network_info() {
default_if="$(netstat -rnf inet | awk '/^default/{print $8}')"
if [ -z "$default_if" ] ; then
echo "No conn"
elif ifconfig "$default_if" | grep -q IEEE802.11 ; then
wireless_info "$default_if"
else
eth_info "$default_if"
fi
}
ac_status() {
if [ `apm -a` -eq 1 ] ; then
echo "charging"
else
printf "discharging "
if [ `apm -m` != "unknown" ] ; then
minutes="$(apm -m)"
hours="$(echo "$minutes"/60 | bc)"
hours2="$(echo "$minutes"/60 | bc -l)"
minutes="$(echo "(${hours2}-${hours})*60" | bc -l )"
printf "%d hours, %d minutes left" "$hours" "$minutes"
fi
fi
}
cpu_temp() {
sysctl hw.sensors.cpu0.temp0 \
| awk -F= '{print $2}' \
| cut -d' ' -f 1 \
| cut -d'.' -f 1 \
| tr -d '\n'
printf "c"
}
cpu_fan() {
sysctl hw \
| grep fan \
| awk -F= '{print $2;exit}' \
| cut -d' ' -f 1 \
| tr -d '\n'
printf "rpm"
}
get_status_simple() {
echo \
"Volume: $(sndioctl | awk 'BEGIN{FS="="}{if($1 ~ /output.level/){print ($2+0)*100}}') |"\
"Fan: $(cpu_fan) |"\
"Temp: $(cpu_temp) |"\
"Setperf: $(sysctl hw.setperf | awk -F= '{print $2}') |"\
"Batt: $(apm -l) $(ac_status)|"\
"$(network_info) |"\
"$(date '+%m.%d.%Y %H:%M:%S')"
}
get_status() {
echo \
"Volume: $(sndioctl | awk 'BEGIN{FS="="}{if($1 ~ /output.level/){print ($2+0)*100}}')|"\
"Temp: $(sysctl hw.sensors.cpu0.temp0 | awk -F= '{print $2}')|"\
"Fan: $(sysctl hw | grep fan | awk -F= '{print $2;exit}')|"\
"Cpu Freq: $(sysctl hw.cpuspeed | awk -F= '{print $2}')mhz|"\
"Setperf: $(sysctl hw.setperf | awk -F= '{print $2}')|"\
"Batt: $(apm -l) $(ac_status)|"\
"$(network_info) |"\
"Free Mem: $(_sys_memory)|"\
"uptime: $(_sys_uptime)|"\
"$(date '+%m.%d.%Y %H:%M:%S')"
}
while true ; do
xsetroot -name "$(get_status_simple)"
sleep "$timeout"
done
|