This repository has been archived by the owner on Apr 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgeeklets.txt
198 lines (151 loc) · 4.97 KB
/
geeklets.txt
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
##################
# CPU Meter Code #
##################
free=`top -l 2 | grep "CPU usage" | tail -1 | awk '{printf "%.0f", $7+0}'`
let used=100-$free
let count=5
colour='\033[0;32m'
echo "CPU \c"
while [ $count -le 100 ]
do
if [ $count -le $used ]
then
if [ $count -le 50 ]
then
echo "\033[1;32m|\c" # green
colour='\033[0;32m'
elif [ $count -le 75 ]
then
echo "\033[1;33m|\c" # yellow
colour='\033[0;33m'
elif [ $count -le 100 ]
then
echo "\033[1;31m|\c" # red
colour='\033[0;31m'
fi
else
echo " \c"
fi
let count=${count}+5
done
# Default Output. Place a # (comment) sign at the start of the next "echo" line below if you wish to used the Extended output.
# echo "$colour $used%\c"
# Extended output. Remove the # (comment) sign from the next "echo" line below to use.
echo "$colour $used% Utilisation\c"
unset colour
echo "\033[0;39m"
##################
# RAM Meter Code #
##################
used_ram=`top -l 1 | awk '/PhysMem/ {print $2}' | sed "s/M//"`
free_ram=`top -l 1 | awk '/PhysMem/ {print $6}' | sed "s/M//"`
let total_ram=$used_ram+$free_ram
used_percent=$(echo "scale=2; $used_ram / $total_ram * 100" | bc)
used_percent=`echo $used_percent | cut -d . -f 1`
# convert free_ram to GB not MB for the Extended output feature
free_ram=$(echo "scale=2; $free_ram / 1024" | bc)
let count=5
colour='\033[0;32m'
echo "RAM \c"
while [ $count -le 100 ]
do
if [ $count -le $used_percent ]
then
if [ $count -le 50 ]
then
echo "\033[1;32m|\c" # green
colour='\033[0;32m'
elif [ $count -le 75 ]
then
echo "\033[1;33m|\c" # yellow
colour='\033[0;33m'
elif [ $count -le 100 ]
then
echo "\033[1;31m|\c" # red
colour='\033[0;31m'
fi
else
echo " \c"
fi
let count=${count}+5
done
# Default output. Place a # (comment) sign at the start of the next "echo" line if wishing top use the Extended output.
# echo "$colour $used_percent%\c"
# Extended output. Remove the # sign from the "echo" line below to use.
echo "$colour $used_percent% Used, ${free_ram}GB Free\c"
unset colour
echo "\033[0;39m"
######################
# BATTERY Meter Code #
######################
max_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Capacity | awk '{print $5 }'`
actual_charge=`system_profiler -detailLevel basic SPPowerDataType | grep mAh | grep Remaining | awk '{print $4 }'`
avail=$(echo "scale=2; $actual_charge / $max_charge * 100" | bc)
avail=`echo $avail | cut -d . -f 1`
let count=5
# set colour to red in case batt is less than 5% as it won't do the while (colour coding) loop if $avail is less than the counter.
colour='\033[0;31m'
bar=''
echo "Bat \c"
while [ $count -le 100 ]
do
if [ $count -le $avail ]
then
if [ $count -le 25 ]
then
bar="\033[1;31m|$bar" # red
colour='\033[0;31m'
elif [ $count -le 50 ]
then
bar="\033[1;33m|$bar" # yellow
colour='\033[0;33m'
elif [ $count -gt 50 ]
then
bar="\033[1;32m|$bar" # green
colour='\033[0;32m'
fi
else
bar=" $bar"
fi
let count=${count}+5
done
# Default output. Place a # (comment) sign at the start of the next "echo" line below if you wish to use the Extended output.
#echo "$bar$colour $avail%\c"
# Extended output. Remove the # (comment) sign from the next "echo" line below to use.
echo "$bar$colour $avail% charged, $actual_charge(mAh) Remain\c"
unset bar
unset colour
echo "\033[0;39m"
echo ""
#####################
# WIFI Network Code #
#####################
# Script to get the current ip addresses in use
# N.B. this was written for my Macbook Pro and iMac.
# Check the en0, en1, etc assignments for a Mac Pro
# which has 2 ethernet ports, not 1, also
# Macbook Air has no ethernet port
#SMC 1.5 and EFI 2.3 Updates (Nov. 2011) have killed this method for obtaining SSID info
#wifi_network=`system_profiler -detailLevel basic SPAirPortDataType | head -25 | tail -1 | awk '{print $1}' | sed "s/://"`
wifi_network=`/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F: '/ SSID: / {print $2}' | sed -e 's/SSID: //' | sed -e 's/ //'`
wifi=`ifconfig en0 | grep "broadcast" | awk '{print $2}'`
ethe=`ifconfig en3 | grep "broadcast" | awk '{print $2}'`
if [ "$wifi" != "" ]
then
echo "🔵 Wireless ip: $wifi on $wifi_network"
else
echo "🔴 Wireless ip: NO CONNECTION"
fi
if [ "$ethe" != "" ]
then
echo "🔵 Ethernet ip: $ethe"
else
echo "🔴 Ethernet ip: NO CONNECTION"
fi
external=`curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d '<'`
if [ "$external" != "" ]
then
echo "🌎 External ip: $external"
else
echo "🔴 NO INTERNET CONNECTION"
fi