-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacHUD.sh.save
32 lines (26 loc) · 1.09 KB
/
MacHUD.sh.save
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
#!/bin/sh
#functions
cd "$(dirname $0)"
printBars() {
num=$1
retVal=$(printf "%-${num}s" "|")
echo "${retVal// /|}"
}
#Insert find line number function to find line number of element.
#Disk Space Calculations
usedSpace=$(df -hl | grep '/dev/disk1' | awk '{sub("%","");print $5}')
sed -i'' -e "9s/.*/$usedSpace%/" MacHUD.html
numUsedBars=$(($usedSpace/5))
usedBars="$(printBars $numUsedBars)"
numFreeBars=$((20-$numUsedBars))
freeBars="$(printBars $numFreeBars)"
sed -i '' -e "11s/.*/<barsUsed>$usedBars<\/barsUsed><barsFree>$freeBars<\/barsFree>/" MacHUD.html
#Find Active Network Adapter(s)
#Print IP, subnet mask, gateway, DNS servers, and domain suffix
wiFiAddy="$(ifconfig en0 | awk '{ print $2}' | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}")"
sed -i '' -e "16s/.*/$wiFiAddy/" MacHUD.html
#Find External IP
#Print IP and provider
extAddyJson="$(curl -s http://ip-api.com/json)"
isp="$(echo $extAddyJson | awk 'BEGIN { FS = "," } ; { print $5 }' | sed 's/\"//g' | sed 's/isp:/ISP: /g')"
extAddy="$(echo $extAddyJson | awk 'BEGIN { FS = "," } ; { print $9 }' | sed 's/\"//g' | sed 's/query:/IP: /g')"