Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
You're awesome I've looked all over for that script thanks a lot. Is there a way to put in the Degrees symbol?
Just add it to the end of each of those curl statements, outside of the parenthesis.

Code:
zip=14221 

temp_f=$(curl -s "http://xml.weather.yahoo.com/forecastrss?p=$zip&u=f" | egrep -o 'temp="[^"]*"' | sed -e 's/temp="//g' -e 's/"//g')°
temp_c=$(curl -s "http://xml.weather.yahoo.com/forecastrss?p=$zip&u=c" | egrep -o 'temp="[^"]*"' | sed -e 's/temp="//g' -e 's/"//g')°

echo "The temp in F is $temp_f, the temp in C is $temp_c"
 
Can someone write a script that would combine the amount of free RAM with the amount of inactive RAM?

So if I had 2GB of free RAM and 2.5GB of inactive RAM, I would want it to display as "Available RAM 4.5GB."

Is that possible?
 
help adding making a 2-month calendar

I am using this code to display the month with the current day displayed in another color. I would like some help modifying the script so the calendar for the next month is shown below the current month.

Code:
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[1;32m${today}\033[0m}";

Thanks for your help!
 
I am using this code to display the month with the current day displayed in another color. I would like some help modifying the script so the calendar for the next month is shown below the current month.

Code:
cal_head=`cal | head -1`; cal_tail=`cal | tail -7`; today=`date "+%e"`; echo "$cal_head"; echo "${cal_tail/${today}/\033[1;32m${today}\033[0m}";

Thanks for your help!

here you go.

Code:
#!/bin/bash

# Helper function to display a month in the past or future
Cal() { cal $(date -v$1m '+%m %Y') | sed 's/^/ /';}

# Next month
Cal +1

+1 is next month, -1 past month, but you can also do +2, etc.
 
Can someone write a script that would combine the amount of free RAM with the amount of inactive RAM?

So if I had 2GB of free RAM and 2.5GB of inactive RAM, I would want it to display as "Available RAM 4.5GB."

Is that possible?

Most of the work was done back in post #2724 (along with the tweak for "gigs" given above in #2727).

It would become...

vm_stat |awk '/ (free|speculative|inactive):/ {x+=$NF/256}
END {printf "Available RAM: %.2fG\n", x/1024}'
 
Most of the work was done back in post #2724 (along with the tweak for "gigs" given above in #2727).

It would become...

vm_stat |awk '/ (free|speculative|inactive):/ {x+=$NF/256}
END {printf "Available RAM: %.2fG\n", x/1024}'

Sweet, thank you. I'm quite new at this scripting stuff.

BTW, do you have a breath mint? ;)
 
Thanks so much! Works like a charm. Is there any way to put a line break between the two calendars?

here you go.

Code:
#!/bin/bash

# Helper function to display a month in the past or future
Cal() { cal $(date -v$1m '+%m %Y') | sed 's/^/ /';}

# Next month
Cal +1

+1 is next month, -1 past month, but you can also do +2, etc.
 
Here's what I've got currently.

Time and date bits are the standard shell scripts. The current iTunes track is a modification of an AppleScript that I think I found in this thread.

The 1:55 / 3:23 is the position and total time of the current iTunes track. That one took a lot of thinking. When I found what worked, I felt kind of silly because it was so close to what I had before.

The font is GungSeo of one size or another in the color Snow at an opacity of 68%. Picture can be found here: http://commons.wikimedia.org/wiki/File:Space_Shuttle_Discovery.png.
 

Attachments

  • Screen shot 2011-01-28 at 11.57.06 PM.jpg
    Screen shot 2011-01-28 at 11.57.06 PM.jpg
    271.6 KB · Views: 265
Last edited:
Help ?

I need some help with my iTunesScript:

Code:
tell application "System Events" to if not (process "iTunes" exists) then return
tell application "iTunes"
	set spacer to "     "
	set myName to name of current track & "
	"
	set myArtist to artist of current track
	set myGenre to spacer & "(" & genre of current track & ")"
	set myGrouping to spacer & "{" & grouping of current track & "}"
	set myAlbum to album of current track
	if myAlbum is not "" then
		set myAlbum to " - " & myAlbum
	end if
	set myRating to round ((rating of current track) / 20)
	if myRating is 1 then
		set myRating to "*"
	else if myRating is 2 then
		set myRating to "**"
	else if myRating is 3 then
		set myRating to "***"
	else if myRating is 4 then
		set myRating to "****"
	else if myRating is 5 then
		set myRating to "*****"
	else
		set myRating to "NO RATING"
	end if
	set myRating to spacer & myRating
	set myPosition to player position
	set myDuration to duration of current track
	set myPercent to spacer & (round (myPosition / myDuration * 100)) & "%"
	set output to myName & myArtist
end tell

The problem: The song information is still displayed on the screen when the song is paused. But i don't know how to change or add anything to the code to do this.

Could someone do it for me ?

Thanks !!
 
I need some help with my iTunesScript:

Code:
tell application "System Events" to if not (process "iTunes" exists) then return
tell application "iTunes"
	set spacer to "     "
	set myName to name of current track & "
	"
	set myArtist to artist of current track
	set myGenre to spacer & "(" & genre of current track & ")"
	set myGrouping to spacer & "{" & grouping of current track & "}"
	set myAlbum to album of current track
	if myAlbum is not "" then
		set myAlbum to " - " & myAlbum
	end if
	set myRating to round ((rating of current track) / 20)
	if myRating is 1 then
		set myRating to "*"
	else if myRating is 2 then
		set myRating to "**"
	else if myRating is 3 then
		set myRating to "***"
	else if myRating is 4 then
		set myRating to "****"
	else if myRating is 5 then
		set myRating to "*****"
	else
		set myRating to "NO RATING"
	end if
	set myRating to spacer & myRating
	set myPosition to player position
	set myDuration to duration of current track
	set myPercent to spacer & (round (myPosition / myDuration * 100)) & "%"
	set output to myName & myArtist
end tell

The problem: The song information is still displayed on the screen when the song is paused. But i don't know how to change or add anything to the code to do this.

Could someone do it for me ?

Thanks !!
add this to your code, just after "tell application "iTunes""
Code:
try
		set playerstate to (get player state)
	end try
	if playerstate = paused then
		set output to "❚❚ "
	else
and dont forget the end if at the end! ;)

Here's what I've got currently.

Time and date bits are the standard shell scripts. The current iTunes track is a modification of an AppleScript that I think I found in this thread.

The 1:55 / 3:23 is the position and total time of the current iTunes track. That one took a lot of thinking. When I found what worked, I felt kind of silly because it was so close to what I had before.

The font is GungSeo of one size or another at an opacity of 68%. Picture can be found here: http://commons.wikimedia.org/wiki/File:Space_Shuttle_Discovery.png.

and how did you put the space shuttle in front of your codes? photoshop?
thanks!
 
and how did you put the space shuttle in front of your codes? photoshop?
thanks!

I cut the shuttle out with Paint.NET (similar to The GIMP) and selected crop to selection (that makes placement so much easier). Then I set the desktop background to the unmodified version of the picture and placed all my geeklets. Finally, I made a new group and opened an image geeklet in it that contained the cut out shuttle. The hardest part is adjusting the size of the cut out and positioning it correctly.

For anyone who wants my track time thing, here's the script. It's a heavily modified version of the track name and artist script. If anyone knows how I can get "time of current track" to come out as 3.07, rather than 3:07, could you tell me? It would match everything else much better.

Code:
on run
	set info to ""
	set info2 to ""
	tell application "System Events"
		set num to count (every process whose name is "iTunes")
	end tell
	if num > 0 then
		tell application "iTunes"
			set when to player position
			set when1 to when div 60
			set when2 to when mod 60
			if when2 < 10 then set when2 to "0" & when2
			set long to time of current track
			set info to (when1 & ":" & when2 & " / " & long) as string
		end tell
	end if
	return info
end run
 
Last edited:
I got bored of my space shuttle, so I changed it around to this.

I would really like the weather image from Yahoo weather, but I've tried everything and I can't get it. I think part of the problem is all the things have been made for Geektool 2, not 3. If you've got a working weather image, could you post the code? Thanks in advance.

I added current weather conditions, forecast, and the iTunes player status (either playing or paused).
 

Attachments

  • Screen shot 2011-01-29 at 10.14.56 PM.jpg
    Screen shot 2011-01-29 at 10.14.56 PM.jpg
    265 KB · Views: 214
I got bored of my space shuttle, so I changed it around to this.

I would really like the weather image from Yahoo weather, but I've tried everything and I can't get it. I think part of the problem is all the things have been made for Geektool 2, not 3. If you've got a working weather image, could you post the code? Thanks in advance.

I added current weather conditions, forecast, and the iTunes player status (either playing or paused).

no offence, but some people really need to understand that some questions have been answered before. this was on last page. post #2722.
 
I've been spending a lot of time reading the past few days, thanks guys for laying down the groundwork for those of us new to the game :).

I've done a search on this thread but I can't find an answer. I'm aware of xtacocorex's script for grabbing weather information, but it seems that it only grabs the current condition. I've looked at the xml feed and it also has forecast for the next 2 days which I would find valuable to have displayed. Is there any way to modify the script to scrape the xml feed for the forecast info too (not really well versed in python, let alone programming for that matter)? I've noticed quite a few people managed to get the forecasted conditions on their desktops and I was wondering how that's being done. Thanks!
 
Try this:

Code:
curl --silent "<URLFromRSSFeed>u=f" | grep -e "Forecast:" -A 2 | tail -n 2 | sed -e 's/<br \/>//' -e 's/<BR \/>//' | sed "s/\(.*\)\.\ \(.*\)/\1\?\2/" | tr "?" "\n" | sed "s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?High\: \1\ Low\:\ \2/" | sed "s/\?\(.*\)/\\1/"

Change the "u=f" part to "u=c" for a Celsius measurement. Change the feed:// to http:// after putting the URL in and removing the < and >.
 
I've been spending a lot of time reading the past few days, thanks guys for laying down the groundwork for those of us new to the game :).

I've done a search on this thread but I can't find an answer. I'm aware of xtacocorex's script for grabbing weather information, but it seems that it only grabs the current condition. I've looked at the xml feed and it also has forecast for the next 2 days which I would find valuable to have displayed. Is there any way to modify the script to scrape the xml feed for the forecast info too (not really well versed in python, let alone programming for that matter)? I've noticed quite a few people managed to get the forecasted conditions on their desktops and I was wondering how that's being done. Thanks!

here's the one I use... not pretty, but it works.

Code:
curl  "http://weather.yahooapis.com/forecastrss?p=CAXX0301&u=c" | grep -e "Forecast:" -A 3 | tail -n 3 | sed -e 's/<br \/>//' -e 's/<BR \/>//' | sed "s/\(.*\)\.\ \(.*\)/\1\?\2/" | tr "?" "\n" | sed "s/High\:\ \(.*\)\ Low\:\ \(.*\)/\?H\: \1\  L\:\ \2/" | sed "s/\?\(.*\)/\\1/"

Shows up as:
Tue: Snow Showers
H: -11 L: -16
Wed: Heavy Snow
H: -10 L: -15

edit: yeah, well its exactly the same that Shake 'n' Bake put... never mind... :p
 
Last edited:
Hey folks, I'm trying to set up a quote generator, but I'm running into some issues. I'm trying to modify the following code to display only quotes from certain categories from quotedb.com.
Code:
quotesource=http://www.quotedb.com/quote/quote.php?action=random_quote

curl -s ${quotesource} |sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | \
    sed -e s/document.write\(\'//g | \
    sed -e s/\'\)\;//g | \
    sed 's/More quotes from /  -- /g'| \
    sed '$!N;s/\n/ /'

On quotedb.com's quote generator page, you can change the categories in the javascript like this: http://www.quotedb.com/quote/quote.php?action=random_quote&c[126]=126&=&

That should only give you quotes from Computers. However, when I try to add the "&c[126]=126&=&" bit to the end of the quotesource variable, I don't get anything. Help?

Also, is there any way to get a drop shadow or something behind the text? My background changes every 15 min and some are very light and some are very dark, so I can't find a font that looks good on all, so if the font was, say black with a white outline, that would probably be perfect.
 
ČĆЊ

Hi guys.
I'm using this script for RSS feed in my geektool:


#!/bin/sh

URL="http://www.b92.net/info/rss/vesti.xml"

if [ $# -eq 1 ] ; then
headarg=$(( $1 * 2 ))
else
headarg="-8"
fi

curl --silent "$URL" | grep -E '(title>|description>)' | \
sed -n '4,$p' | \
sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/ /' \
-e 's/<\/description>//' | \
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/<[^>]*>//g' |
head $headarg | sed G | fmt


It works fine but I can't get the serbian letters ŽĆČЊ display correctly. It just skips these letters. I tried to change encoding within the geektool options but none of it works.

Is there a way to force the encoding inside the script?
Thanks.
 

Attachments

  • Screen shot 2011-02-04 at 18.45.36.jpg
    Screen shot 2011-02-04 at 18.45.36.jpg
    363.2 KB · Views: 518
Hi guys.
I'm using this script for RSS feed in my geektool:


#!/bin/sh

URL="http://www.b92.net/info/rss/vesti.xml"

if [ $# -eq 1 ] ; then
headarg=$(( $1 * 2 ))
else
headarg="-8"
fi

curl --silent "$URL" | grep -E '(title>|description>)' | \
sed -n '4,$p' | \
sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/ /' \
-e 's/<\/description>//' | \
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/<[^>]*>//g' |
head $headarg | sed G | fmt


It works fine but I can't get the serbian letters ŽĆČЊ display correctly. It just skips these letters. I tried to change encoding within the geektool options but none of it works.

Is there a way to force the encoding inside the script?
Thanks.



You could try setting the locale in the shell script using the LANG environment variable. However I don't know what locale you'd specifically need. :(
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.