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.
I think you need to change the Geeklet from Ascii encoding to Unicode. The python script works perfect in the terminal. If changing the encoding doesn't work, it's probably something in Applescript.

Yeah it's definitely a problem in Applescript (that error message is from AS).

I will see if anyone on #python knows. The script works perfect besides that!

Thanks again!
 
My android/iphone desktop

A result of too much time on my hands and a lot of help from this thread.
 

Attachments

  • Screen shot 2011-07-03 at 11.50.44 PM.png
    Screen shot 2011-07-03 at 11.50.44 PM.png
    853.2 KB · Views: 371
Mac OS X 10.7 Lion Compatibility?

Has anyone tried using GeekTool with Lion yet?

I can't edit, create, or select any geeklets — so it appears that GeekTool is broken with 10.7.

:-/
 
I was wondering if anyone knew the script for a list of recently played songs like this:

music.jpg


I was able to make a list, but instead of recently played, it was just the 5 songs that were listed before the current song on iTunes.

Also, does anyone have a script for a progress bar for iTunes? I found one where the bar would get longer as the song plays, but I want one where the full length of the bar is already shown and it gets shaded in as the song plays.

Any help would be greatly appreciated!
 
Last edited:
I think you need to change the Geeklet from Ascii encoding to Unicode. The python script works perfect in the terminal. If changing the encoding doesn't work, it's probably something in Applescript.

xta, I fixed it. The problem -- we were trying to pass a bytestring and a unicode string at the same time.

By encoding them all to be UTF-8 AppleScript accepted them for display:

Code:
    if (opts.temp):
        if (opts.deg):
            print currTEMP.encode("utf-8") + unichr(176).encode("utf-8") + unit.encode("utf-8")
        else:
            print currTEMP + unit
 
xta, I fixed it. The problem -- we were trying to pass a bytestring and a unicode string at the same time.

By encoding them all to be UTF-8 AppleScript accepted them for display:

Code:
    if (opts.temp):
        if (opts.deg):
            print currTEMP.encode("utf-8") + unichr(176).encode("utf-8") + unit.encode("utf-8")
        else:
            print currTEMP + unit
Ah, that makes sense. Thanks for the heads up!
 
Thanks to everyone for scripting help

I did not know a thing about bash scripts until I found geektool and this forum. I would like to share what I have done and welcome all comments.
Maybe this will help someone. Thanks again to all.

Here is an example of multiple scripts I was able to put together.

Code:
#!/bin/sh

DAYNIGHT()
{
	sunset=$(grep ":astronomy" ~/tmp/yahooweather.xml | sed -e 's/.*="//' -e 's/ pm.*//' -e 's/://')
	#echo "$sunset"
	sunrise=$(grep ":astronomy" ~/tmp/yahooweather.xml | sed -e 's/.*sunrise="//' -e 's/ am.*//' -e 's/://')
	#echo "$sunrise"
	guiddate=$(grep "guid" ~/tmp/yahooweather.xml | sed -e 's/.*USCO0038//g' -e 's/CDT.*//g' -e 's/_//g' -e 's/........//')
	#correct sunset to 24 hour time
	sunset=$(($sunset+1200))
	day=d
	#echo "$guiddate"
	#echo "$day"
	#after sunset
	if [ $guiddate -gt $sunset ] ; then
		day=n
	fi
	#and before sunrise ?
	if [ $guiddate -lt $sunrise ] ; then
		day=n
	fi
	echo "$day"
}

GETDATA()
{
	#check internet access
	curl --silent 'http://weather.yahooapis.com/forecastrss?p=USCO0038&u=f' > /dev/null
	#if error code is 0, internet is available, create yahooweather.xml
	if [ "$?" = 0 ] ; then
		curl --silent 'http://weather.yahooapis.com/forecastrss?p=USCO0038&u=f' > ~/tmp/yahooweather.xml
	fi
}

COPYWEATHERIMG()
{
	day=$(DAYNIGHT)
	code=$(grep ":condition" ~/tmp/yahooweather.xml | sed -e 's/.*code="//' -e 's/"  temp.*//')
	cp ~/weathericons/"$code$day".gif ~/tmp/"$code$day".gif
	mv -f ~/tmp/"$code$day".gif ~/tmp/weathericon.gif
}

#Check to see if yahooweather.xml exists, if not get it
#If you can't get it, exit
if [ ! -f ~/tmp/yahooweather.xml ] ; then
	GETDATA
	if [ ! -f ~/tmp/yahooweather.xml ] ; then
		echo "Unable to get weather info."
		echo "Check internet connection"
		exit
	fi
fi

#compare current date to yahoo build date, download yahooapi if > 1 hour
currdate=$(date +%Y%m%d%H%M)
guiddate=$(grep "guid" ~/tmp/yahooweather.xml | sed -e 's/.*USCO0038//g' -e 's/CDT.*//g' -e 's/_//g')
#if hour is less than 10 add a 0, 9 -> 09
if [ $guiddate -lt 200000000000 ] ; then
	guiddate=$(echo $guiddate | sed 's/......../&0/')
fi
#get new data if older than 1 hour
guiddate=$(($guiddate + 100))
if [ $currdate -gt $guiddate ] ; then
	GETDATA
	COPYWEATHERIMG
fi
city=$(grep "yweather:location" ~/tmp/yahooweather.xml | sed -e 's/.*city=//g' -e 's/reg.*\/>//g' -e 's/"//g')
state=$(grep ":location" ~/tmp/yahooweather.xml | sed -e 's/.*region=//g' -e 's/coun.*//g' -e 's/"//g')
echo $city, $state
grep "pubDate" ~/tmp/yahooweather.xml | sed -e 's/<pubDate>//' -e 's/<.*//'
grep -A1 "Current Conditions" ~/tmp/yahooweather.xml | tail -n1 | sed 's/<.*//'
grep ":astronomy" ~/tmp/yahooweather.xml | sed -e 's/.*sunrise="/Sunrise  /g' -e 's/sunset.*//g' -e 's/"//g'
grep ":astronomy" ~/tmp/yahooweather.xml | sed -e 's/.*sunset="/Sunset  /g' -e 's/\/.*//g' -e 's/"//g'
grep ":atmosphere" ~/tmp/yahooweather.xml | sed -e 's/.*humidity="/Humidity /g' -e 's/vis.*//g' -e 's/"//g'
grep ":atmosphere" ~/tmp/yahooweather.xml | sed -e 's/.*pressure="/Pressure /g' -e 's/rising.*//g' -e 's/"//g'
grep ":atmosphere" ~/tmp/yahooweather.xml | sed -e 's/.*rising="/Rising /g' -e 's/\/.*//g' -e 's/"//g'
grep ":atmosphere" ~/tmp/yahooweather.xml | sed -e 's/.*visibility="/Visibility /g' -e 's/press.*//g' -e 's/"//g'
grep ":wind" ~/tmp/yahooweather.xml | sed -e 's/.*chill=/Wind chill /g' -e 's/dire.*//g' -e 's/"//g'
grep ":wind" ~/tmp/yahooweather.xml | sed -e 's/.*direction="/Direction /g' -e 's/speed.*//g' -e 's/"//g'
grep ":wind" ~/tmp/yahooweather.xml | sed -e 's/.*speed="/Speed /g' -e 's/\/.*//g' -e 's/"//g'
grep "Forecast:" ~/tmp/yahooweather.xml -A 2 | tail -n 2 | sed -e 's/<br \/>//' -e 's/\. /?/g' | tr "?" "\n"
 
Please if anyone can help me I'm in dire search of the code for this graph in the top left:

http://i166.photobucket.com/albums/u100/lp_obsession2005/Picture1-3.png

It was give by user lpobsession on page 95, but he never posted the code for the CPU graph usage.

Anyone know how I can do this with Geektool?! Thanks!

ALSO EDIT --

Does anyone have the code to display temperatures in geek tool WITHOUT a third party application?

I wish this forum had a search function for individual threads :(

Does anyone know how to make graphs like this one, or the one in the activity monitor, through GeekTool? Is it even possible?
 
Last edited:
Thanks alot for that python bar mate! I've been messing with it alot, hahaha :p

Well I know this may sound kind of stupid but I'd like to set a script to check wether I'm connected and if yes, display image X, else display image Y. Unfortunately, I'm kind of ignorant on scripting, could anybody help me?

Also I've been messing with lsof -i | grep -E "(ESTABLISHED)" to keep some kind of track of my active connections but I would really like to get rid of the IPv4 and 0t0 columns, any ideas on how I'd do that?
 
Thanks alot for that python bar mate! I've been messing with it alot, hahaha :p

Well I know this may sound kind of stupid but I'd like to set a script to check wether I'm connected and if yes, display image X, else display image Y. Unfortunately, I'm kind of ignorant on scripting, could anybody help me?

Also I've been messing with lsof -i | grep -E "(ESTABLISHED)" to keep some kind of track of my active connections but I would really like to get rid of the IPv4 and 0t0 columns, any ideas on how I'd do that?

lsof -i | grep -E "(ESTABLISHED)" | sed -e 's/IPv4.*0t0//'
 
lsof -i | grep -E "(ESTABLISHED)" | sed -e 's/IPv4.*0t0//'



You, my fellow human, are a being of beautiful and generous helpfulness <3.

Just out of curiosity, if I'm already setting it so filter for established only, do I really need it to appear written on the output? I mean, is there any way to filter for it and yet hide the (ESTABLISHED) part?

You've been of huge help already, thanks alot =)
 
@Zetthy
You can tell sed to delete it.
Code:
lsof -i | grep -E "(ESTABLISHED)" | sed -e 's/IPv4.*0t0//' -e 's/(ESTABLISHED)//g'
 
Sweet! Thanks mike!

Check this out, might be it's of interest to someone:

if curl -f -s http://google.com > /dev/null ; then echo "Connected" ; else echo "Not connected" ; fi ;

Checks whether you're connected and displays the appropriate line. I wanted a more graphical approach, say, an image of my choosing. A solid planet if I'm connected, a transparent one if I'm not.

So I went with:


ON.glet: Image geeklet of a working internet station.
Off.glet: Image geeklet of a disconnected station.

if curl -f -s http://google.com > /dev/null ; then open ON.glet ; else open Off.glet ; fi ;

This has 2 minor flaws:

1) Let's say I'm connected when the script checks the first time. It will open the image Connected but it will LEAVE IT OPEN indefinetly. So if I disconnect before the next check, it will open the image Disconnected but the connected one will still be there. So the script needs an extra line for an "And" command, like "if connected, open ON.glet AND close Off.glet, else open Off.glet AND close ON.glet"

I just don't know how to do that...

Also 2) The command works just fine directly on terminal, however when I add it to geektools nothing happens =(
 
Sweet! Thanks mike!

Check this out, might be it's of interest to someone:

if curl -f -s http://google.com > /dev/null ; then echo "Connected" ; else echo "Not connected" ; fi ;

Checks whether you're connected and displays the appropriate line. I wanted a more graphical approach, say, an image of my choosing. A solid planet if I'm connected, a transparent one if I'm not.

So I went with:


ON.glet: Image geeklet of a working internet station.
Off.glet: Image geeklet of a disconnected station.

if curl -f -s http://google.com > /dev/null ; then open ON.glet ; else open Off.glet ; fi ;

This has 2 minor flaws:

1) Let's say I'm connected when the script checks the first time. It will open the image Connected but it will LEAVE IT OPEN indefinetly. So if I disconnect before the next check, it will open the image Disconnected but the connected one will still be there. So the script needs an extra line for an "And" command, like "if connected, open ON.glet AND close Off.glet, else open Off.glet AND close ON.glet"

I just don't know how to do that...

Also 2) The command works just fine directly on terminal, however when I add it to geektools nothing happens =(

Instead of calling ON.glet and Off.glet in the if-else, I would put a shell cp command to overwrite a temporary image file. Have another geeklet display that image. This would reduce the number of geeklets that you currently have by 1.

Method:
Geeklet 1: Shell
Code:
if curl -f -s http://google.com > /dev/null ; then cp /path/to/on.png /tmp/connstatus.png ; else cp /path/to/off.png /tmp/connstatus.png ; fi ;

Geeklet 2: Image
image location pointed to /tmp/connstatus.png

You'd have to play with refresh rates as I'm sure google won't like you connecting every second.

This is pretty much how I do my solo weather picture; I have a file look at the condition code from yahoo and then it redirects that appropriate image to a temporary png file for display.
 
Last edited:
@Zetthy
You're welcome.
@xtacocorex
I use the method of cp an img to folder then use a geeklet to load the image. The image gets out of sync with the text if the refresh rate is too long. Is there a way, in geektool 3, to programmatically call a geeklet? It appears, to me, that yahoo weather is updated once an hour so my weather image is off by the refresh rate, i.e. 15 minutes. Just curious.
I have used geektool as an excuse to learn shell scripting. I thinking I'm going to step up to python next. :)
Thanks
 
@Zetthy
You're welcome.
@xtacocorex
I use the method of cp an img to folder then use a geeklet to load the image. The image gets out of sync with the text if the refresh rate is too long. Is there a way, in geektool 3, to programmatically call a geeklet? It appears, to me, that yahoo weather is updated once an hour so my weather image is off by the refresh rate, i.e. 15 minutes. Just curious.
I have used geektool as an excuse to learn shell scripting. I thinking I'm going to step up to python next. :)
Thanks

I don't know anything about Geektool 3 since I use Nerdtool; from the stuff I've read, I think you can call a geeklet from Geektool 3, but I haven't tried it.

I think I set 2 of the 4 weather related geeklets of mine to 15 minutes, I think the forecast script doesn't refresh that often.

If you need some python examples, check out the stuff I've posted in this thread. :)
 
Geektool Photo Gallery help

Hello you wonderfully informative people! I have a question that maybe you guys can answer for me.

I'm looking to either create or find a photo gallery script where I can add group feeds from flickr. Im have two problems though.

1- I cant seem to get Flickr feeds to display
2- I would like the images in the gallery to expand and fill the box that I have them in.

Basically I am trying to do a similar desktop set up to the one that I have included an image for (win desktop).

Any help would be greatly appreciated!

5891798907_58365561bc.jpg
 
Hello you wonderfully informative people! I have a question that maybe you guys can answer for me.

I'm looking to either create or find a photo gallery script where I can add group feeds from flickr. Im have two problems though.

1- I cant seem to get Flickr feeds to display
2- I would like the images in the gallery to expand and fill the box that I have them in.

Basically I am trying to do a similar desktop set up to the one that I have included an image for (win desktop).

Any help would be greatly appreciated!

I have a feeling that's going to be very hard to do with Geektool, it might be possible with Geektool 3 which I think can call other Geeklets into existence but I run Nerdtool and don't have the ability to try it currently.

I'm assuming you want to be able to click the picture and go to the corresponding flickr page?

Do you have a link to that Windows program? I'd like to see what it's all about.

I think this would have to be a standalone application which I don't have time to learn the API for OS-X or code something up. :(
 
Use Geektool's Icon mode!

Sweet! Thanks mike!

Check this out, might be it's of interest to someone:

if curl -f -s http://google.com > /dev/null ; then echo "Connected" ; else echo "Not connected" ; fi ;

You can simplify this a LOT since Geektool already includes the capability to display different images for success and failure of a shell command.

Put just this into a shell command:

Code:
curl -f -s [URL="http://google.com/"]http://google.com[/URL] > /dev/null
Then turn on the icon mode in Geektool. You can use the default success/failure icons, which are a green and red dot. Done!

You can put in other things too, like hard drive S.M.A.R.T. status next to your hard drive, as shown here.

http://www.allenjhall.com/content/2...o-show-smart-drive-status-on-the-desktop-osx/

Darryl
 
Hello you wonderfully informative people! I have a question that maybe you guys can answer for me.

I'm looking to either create or find a photo gallery script where I can add group feeds from flickr. Im have two problems though.

1- I cant seem to get Flickr feeds to display
2- I would like the images in the gallery to expand and fill the box that I have them in.

Basically I am trying to do a similar desktop set up to the one that I have included an image for (win desktop).

Any help would be greatly appreciated!

Image

Sorry I can't help you, but I just gotta say: that is one AWESOME desktop!
 
Thanks alot for all the interest and replies guys <3 I'm just not script-savvy at all, so I try ( and usually fail, but I have fun...!) to get creative on workarounds for my lack of knowledge :D I do appreciate all the support and feedback from you, really!
 
can i get an script for battery life? please this thread is too big for me :( thanks
( macbook pro i5 13´2011 version)
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.