Number 3 is my old Weather Underground full forecast. Now I just set a permanent target server on the speedtest network to get more accurate tracking. It was pinging to my own controlled speedtest server, but that stopped working. Number 2 is a bandwidth test, download on the left (top number is last test, bottom is average over last 15), upload on the right. I spent most of my time figuring out all the nasty abbreviated and unintuitive parameters for the deprecated image API, but it worked. GeekTool lets you put transparent images on the desktop, and Google Charts Image API can make transparent images, so it seemed natural. I’d been using my command line bar chart to amuse myself with some analytics, but decided I could do better. Because I don’t like leaving the house if I can’t put the top down. Weather Icon from my homemade set, info fed by Weather Underground.A CPU chart using the Arc font (two-layers, system and user).Given that I spent too much of my Sunday fooling around with my GeekTool setup and did very little of any use, I figured I’d at least show off the results. It's basically a full-blown programming language, designed to deal with text files one line at a time, and it's really useful it's also something you can pick up a little bit at a time, if you're so inclined.Why does Snoop Dogg carry an umbrella? Fo’ Drizzle. Type "man awk" in the terminal for a full description of the command. If max is not greater than zero, then something wrong happened (maybe ioreg doesn't have a line which says "MaxCapacity") and so return the character "?". If the variable max is greater than zero, then take the contents of the array labelled "CurrentCapacity", divide it by max, and multiply by 100. Next it prints out the result of the formula max>0?100*c/max:"?"which is an if-then statement (with the form test?true:false awk stole this notation from C). Second, it defines the variable max to be the contents of the array labelled "MaxCapacity" (which was defined in the first part of the process). First it sets OFMT="%.2f%%", which means to change the output format so that it outputs real numbers with two decimal places followed by a percentage sign (as above). The END segment means to run the following command after you're done reading in standard input. (Unlike in some languages, awk's arrays can be labelled with text, not just numbers.) Whenever column 3 ($3) contains the word "Capacity" ($3~/Capacity), it runs the command "c=$5", which stores the fifth column into an array (a box) labelled with the contents of the third column. This awk command starts by reading in each line of ioreg -l, one at a time. The printf command calculates $10/$5*100 (that is, the 10th column divided by the 5th column, times 100) and prints it as a floating-point number with 2 decimal places ("%.2f") followed by a percentage sign ("%%").Īwk '$3~/Capacity/ ' (So $5 is the 5th column's data and $10 is the 10th column's). This first awk command reads the standard input, one line at a time (if necessary I'm guessing only one line is being sent to it here), and splits the line into columns, the data in column c having the name $c.
0 Comments
Leave a Reply. |