good idea using AppleScript for the weather! never thought about doing it this way...this only shows that you can do pretty much ANYTHING with AS when you know the basis!
- but for your script, we only need to know which image correspond to which weather (sunny is which, rain, etc.)
- and for the forecast, what is the difference between "w-fore0" and "w-fore1" in the forecast. is it tomorrow and the day after tomorrow?
- also, id like to point out that it actually works for all the cities in the world!
and thanks alot for that! this is a lot more flexible and a lot cooler than the old (but practical) way (coolenufforamac)
edit: oh, and while youre at it, what is the script for the "last actions" there, it could be pretty useful!![]()
echo "WAN :" `curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`
echo "LAN :" `ifconfig en0 | grep "inet " | awk '{print $2}'`
#!/bin/sh
# created by chris helming.
# chris dot helming at gmail
# get the current number of bytes in and bytes out
myvar1=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in
myvar3=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out
#wait one second
sleep 1
# get the number of bytes in and out one second later
myvar2=`netstat -ib | grep -e "en0" -m 1 | awk '{print $7}'` # bytes in again
myvar4=`netstat -ib | grep -e "en0" -m 1 | awk '{print $10}'` # bytes out again
# find the difference between bytes in and out during that one second
subin=$(($myvar2 - $myvar1))
subout=$(($myvar4 - $myvar3))
# convert bytes to kilobytes
kbin=`echo "scale=2; $subin/1024;" | bc`
kbout=`echo "scale=2; $subout/1024;" | bc`
# print the results
echo "$kbin Kb/sec | $kbout Kb/sec"
echo "WiFi :" `ifconfig en1 | grep "inet " | awk '{print $2}'`
#!/bin/sh
# created by chris helming.
# chris dot helming at gmail
# get the current number of bytes in and bytes out
myvar1=`netstat -ib | grep -e "en1" -m 1 | awk '{print $7}'` # bytes in
myvar3=`netstat -ib | grep -e "en1" -m 1 | awk '{print $10}'` # bytes out
#wait one second
sleep 1
# get the number of bytes in and out one second later
myvar2=`netstat -ib | grep -e "en1" -m 1 | awk '{print $7}'` # bytes in again
myvar4=`netstat -ib | grep -e "en1" -m 1 | awk '{print $10}'` # bytes out again
# find the difference between bytes in and out during that one second
subin=$(($myvar2 - $myvar1))
subout=$(($myvar4 - $myvar3))
# convert bytes to kilobytes
kbin=`echo "scale=2; $subin/1024;" | bc`
kbout=`echo "scale=2; $subout/1024;" | bc`
# print the results
echo "$kbin Kb/sec | $kbout Kb/sec"
OK. First the answers to the questions
To get the corresponding codes for the weather icons, goto:
http://developer.yahoo.com/weather/
There is a condition codes table at the end of the page. If you use a different set of icons, just use the numbers as the file name. Like:
0.png
As for the variables, w_fore0 and others similarly named will be for the current date. w_fore1 will be for tomorrow's date. Yahoo API doesn't expose any more data into the future.
You asked about a last actions script. Are you talking about my my time machine log? Or my CPU/Memory/uptime?
eyekyu asked for the IP geekets. Here they are:
[...]
I have the data rate refresh at a 3 sec interval. Anymore tends to make the CPU usage climb quickly. Also, these are not my scripts, I cribed them from someone else (who I have forgotten about now, sorry!)
Thanks for the feedback. Any thoughts to the overall look?
http://www.flickr.com/photos/24907007@N08/3409438091/
http://www.techlifeweb.com/2008/12/16/how-to-find-your-facebook-status-rss-feed/#comment-3518
1. It looks like GeekTool havent been updated since Leopard. So does it work perfectly fine on Snow Leopard?
2. All this facny stuff does it uses a lot of resources? Specially if you are running on a battery?
1. Yes.
2. No.
Well it depends on what you consider alotYahoo Widgets uses more resources, but with GeekTool running my layout, I average between 5-10% CPU usage.
As far as battery life constant CPU usage COULD effect it, but the biggest draw of power in a moden laptop is the screen backlight. Compared to that, no, Geektool isn't a battery hog.
So you guys mainly use it as a replacement for Dashboard with all those widgets?
I just like being able to tweak it. If I use Yahoo Widgets (Konfabulator) or the Dashboard, I am constrained to what it available. I am not a software developer, so this lets me customize to my taste (and with consistancy).
That said, the other options are GREAT tools. Did you know you can use Dashboard widgets right on the desktop?
Actually no, im on my second month with mac so if you dont mind enlighten me
So my sunrise has stopped working on Geektool??
It just displays the sunset time in the sunrise spot??
So they both say 8:50pm
curl --silent "http://weather.yahoo.com/united-states/washington/lynnwood-12798909/" | grep "Sunrise" | sed -e 's/.*\<dt\>Sunrise:\<\/dt\>\<dd\>/Sunrise: /' -e 's/<.*//'
ok. now i need help.
i'm trying to do the "facebook notification" geeklet the way that Roebedodoes it. he uses automator (a program that I never used before! and holy jesus its powerful!)HTML:http://www.flickr.com/photos/24907007@N08/3409438091/
i got everything perfect, the automator workflow, the first geeklet (automator runner), the text file works like a charm, and the only thing i'm missing is the the head geeklet, to show the text file...
and if youre having trouble searching for the facebook rss feed, go here.HTML:http://www.techlifeweb.com/2008/12/16/how-to-find-your-facebook-status-rss-feed/#comment-3518
and thanks noobsauce for reminding me this!
edit: found how to take off a part of the text file... just put a "Filter Paragraphs" (in "text") just before the "new text file" and put something like end with ".." it worked for me!
still cant find how to display a text file... i feel really dumb now...
edit2: finally got it to work... had to change the output encoding to mac roman... and the shell command cat [/path/to/file.txt] works better than the file geeklet... you read the first line when you adjust the size, and not the last...
@angelwatt or anyone else that can helpAttached is a 3-month calendar with the current month progress and day highlighted. Below is the code for it.
There are escaped characters on line 3. They are entered by doing a control+q esc (It's invisible when typed) and go right before the two [ chars toward the end of the line. When used inside a double quote area, you can use \033 instead, like on line 2. The coloring is done with ANSI color does. This page list the small list of codes.Code:cal -m $(($(date +%m)-1)) | sed -e s'/^/ /' echo "\033[32m\c" cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ [42;30m\1[0m /g')/" cal -m $(($(date +%m)+1)) | sed -e s'/^/ /'
@angelwatt or anyone else that can help
i used the code above for this and next month but from today (a new month) the code for next month has stopped working. Can anyone help me out?
This is the code:
cal -m $(($(date +%m)+1)) | sed -e s'/^/ /'
Many thanks
cal -m $(date -v +1m | cut -f 2 -d ' ') | sed -e s'/^/ /'
Thanks very much. For you, Sir:Yeah that doesn't work for me when I ran it either, so after a quick rewrite, this code should work for next month....
Code:cal -m $(date -v +1m | cut -f 2 -d ' ') | sed -e s'/^/ /'
@angelwatt or anyone else that can help
i used the code above for this and next month but from today (a new month) the code for next month has stopped working. Can anyone help me out?
cal -m $(($[10#$(date +%m)]-1)) | sed -e s'/^/ /'
echo "\033[32m\c"
cal | sed "s/^/ /;s/$/ /;s/ $(date +%e | sed s'/ //') /$(date +%e | sed -e s'/ //' -e s'/\(.*\)/ [42;30m\1[0m /g')/"
cal -m $(($[10#$(date +%m)]+1)) | sed -e s'/^/ /'
osascript <<eos
tell application "Mail"
try
set {msgs, _a, _max} to {"", 0, 18}
-- Sort messages by date received in descending order
set theList to messages in inbox
script bs
property alist : theList
end script
set theCount to length of bs's alist
if theCount ≥ 2 then
repeat with indexA from theCount to 1 by -1
repeat with indexB from 1 to indexA - 1
if (date received of item indexB of bs's alist) < (date received of item (indexB + 1) of bs's alist) then
set temp to item indexB of bs's alist
set item indexB of bs's alist to item (indexB + 1) of bs's alist
set item (indexB + 1) of bs's alist to temp
end if
end repeat
end repeat
end if
set allmsgs to bs's alist
repeat with _msg in allmsgs
if read status of _msg is false then
set _a to _a + 1
set msgs to msgs & "
" & _a & ". "
if _a < 10 then set msgs to msgs & space
set msgs to msgs & "[1;32m"
set msgs to msgs & subject of _msg & "[0m"
end if
end repeat
repeat with _msg in allmsgs
repeat 1 times
if _a is equal to _max then exit repeat
if read status of _msg is false then exit repeat
set _a to _a + 1
set msgs to msgs & "
" & _a & ". "
if _a < 10 then set msgs to msgs & space
if read status of _msg is false then set msgs to msgs & "[1;32m"
set msgs to msgs & subject of _msg & "[0m"
end repeat
end repeat
msgs
on error estr
estr
end try
end tell
eos
osascript <<eos
global _max, _subjectWidth
set _max to 18
set _subjectWidth to 10
tell application "Mail"
set {msgs, _a} to {"", 0}
-- Sort messages by date received in descending order
set theList to messages in inbox
script bs
property alist : theList
end script
set theCount to length of bs's alist
if theCount ≥ 2 then
repeat with indexA from theCount to 1 by -1
repeat with indexB from 1 to indexA - 1
if (date received of item indexB of bs's alist) < (date received of item (indexB + 1) of bs's alist) then
set temp to item indexB of bs's alist
set item indexB of bs's alist to item (indexB + 1) of bs's alist
set item (indexB + 1) of bs's alist to temp
end if
end repeat
end repeat
end if
set allmsgs to bs's alist
-- Grab all of the unread messages first
repeat with _msg in allmsgs
if read status of _msg is false then
set _a to _a + 1
set msgs to msgs & return
set msgs to msgs & formatMsg(_msg) of me
end if
end repeat
-- Now get all other messages up to max amount
repeat with _msg in allmsgs
repeat 1 times
if _a is equal to _max then exit repeat
if read status of _msg is false then exit repeat
set _a to _a + 1
set msgs to msgs & return
set msgs to msgs & formatMsg(_msg) of me
end repeat
end repeat
msgs
end tell
on formatMsg(_msg)
tell application "Mail"
set msgs to ""
if read status of _msg is false then set msgs to msgs & "[1;32m"
-- Date
set _date to formattedDate(date received of _msg) of me
set msgs to msgs & _date
-- Name
set _name to parseName(sender of _msg as text) of me
set _name to toWidth(_name, _subjectWidth) of me
set msgs to msgs & _name & " | "
-- Subject
set msgs to msgs & subject of _msg
if read status of _msg is false then set msgs to msgs & "[0m"
end tell
return msgs
end formatMsg
on toWidth(_str, _w)
set _r to ""
repeat with _a from 1 to _w
try
set _r to _r & character _a of _str
on error
set _r to _r & " "
end try
end repeat
return _r
end toWidth
on replaceText(find, replace, someText)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set someText to text items of someText
set text item delimiters of AppleScript to replace
set someText to "" & someText
set text item delimiters of AppleScript to prevTIDs
return someText
end replaceText
on parseName(_str)
set predelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to " <"
set _items to text items of _str
set AppleScript's text item delimiters to predelim
set _name to item 1 of _items
set _name to replaceText("\"", "", _name) of me
set _name to replaceText("<", "", _name) of me
set _name to replaceText(">", "", _name) of me
return _name
end parseName
on formattedDate(_date)
set _date to _date
set {_y, _m, _d} to {year of _date, month of _date as number, day of _date}
if _m < 10 then set _m to "0" & _m
if _d < 10 then set _d to "0" & _d
return _y & "-" & _m & "-" & _d & "| "
end formattedDate
eos