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.
Hi. Sorry if this has been posted before. I google'd the thread and didn't find anything.

I wrote a very simple php script to check my gmail accounts. I used php because I could do it quickly, whereas if I used a regular shell script it would have taken me four times as long. I don't think there's much (if any) overhead to doing it this way.

All it does is get the "new" message count and then output it like so:

bob: 3
bob.work: 2

If there are no new messages, it doesn't display anything. You can change that by deleting line 30.

Don't know if anyone will find this useful (notify is probably preferable anyway), but here it is:

PHP:
#!/usr/bin/php
<?php
$accounts = array("NAME1"=>"PASS1","NAME2"=>"PASS2","NAME3"=>"PASS3");

foreach ($accounts as $username=>$password) {
	$c = curl_init('https://gmail.google.com/gmail/feed/atom');
	$headers = array(
		"Host: gmail.google.com",
		"Authorization: Basic ".base64_encode($username.':'.$password),
		"Accept-Encoding: text"
	);
	
	curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
	curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
	curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);
	curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1);
	curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1);

	$page = curl_exec($c);
	curl_close($c);

	preg_match("/<fullcount>(.*)<\/fullcount>/",$page,$count);
	$$username['count'] = $count[1];
}

foreach ($accounts as $username=>$password) {
	if ($$username['count'] != 0)
		echo $username.": ".$$username['count']."\n";
}
?>

Like all other scripts, save it somewhere, make it executable (chmod 755), and then point a geektool script component at it. It takes a little time to talk to Google (~20 secs per account for me), so set the geektool timeout to 30 seconds or so per account, and refresh it every 5 minutes'ish.

Change where it says NAME1, etc. to your account name/s and password (leave the quotes). You can add more or delete the extras. I was able to use either "bob" or "bob@gmail.com" as the account name. Whatever you chose to set here is what will be displayed.

There's more info that gets picked up, like the sender and a snippet of the messages. I guess if someone wants to see all of that I can change it a bit to display that stuff, too. As much as I appreciate really creative and nice looking set-ups, I like to keep my geektools output small, basic, and subtle so that it's always visible but not in the way or distracting. (Personally, I eliminated the line break in the output so that it just shows everything in one small horizontal line.)

Edit: Attached a screenshot. If I had any mail, it would show up in the bottom left. Fancy.
 

Attachments

  • Screen Shot 2011-10-23 at 4.57.30 PM.png
    Screen Shot 2011-10-23 at 4.57.30 PM.png
    352.8 KB · Views: 302
Last edited:
6282404144_3e2e9cd662_b.jpg


This is my first customized Geek Tool desktop. If anyone is interested I will provide the background, overlays and scripts needed.
 
Last edited by a moderator:
This is my contribution

Hi. I've just published one post on my blog about how to create a nice effect to show photos with a polaroid effect. This is how the photos looks like in the end:
border_overlaid_IMG_5162.JPG.png

Sorry, it's in spanish but im pretty sure you know how to translate it :rolleyes:

This is the post http://blogs.fcallem.net/bitio/?p=738 where it's explained step by step but if you just want the script here it is:
Code:
#!/bin/bash

function die(){
echo $@
exit 1
}

#fallback
CONVERT=$(which convert)
[ $? -eq 1 ] && die "Command convert not found. Install imagemagick package" || :

# program setup
SOURCEPHOTOSPATH=~/Fotos/
TARGETPHOTOSPATH=~/Development/geektool/random_photo/images/
FRAMEPATH=~/Development/geektool/random_photo/frames/polaroid-000.png
YEARS=("2003" "2004" "2005" "2006" "2007" "2008" "2009" "2010" "2011")
RAND=$$$(date +%s)
SELECTEDYEAR=${YEARS[$RAND % ${#YEARS[@]} ]}

# clean previous images
cd $TARGETPHOTOSPATH
rm -f *

# select 25 random files (jpgs) of the given year and copy them to
# a new folder. This is done in order to not to remove/destry something
# it wasn't ment to.
find $SOURCEPHOTOSPATH$SELECTEDYEAR -type f -name "*.jpg" -o -name "*.JPG" |
while read x; do echo "`expr $RANDOM % 1000`:$x"; done | sort -n |
sed 's/[0-9]*://' | head -25 | while read result; do cp $result $TARGETPHOTOSPATH; done

# modify every image with the selected frame
for image in `ls .`
do
  echo "processing file $image ..."
  # create the appropiated thumbnail to fit into the frame
  $($CONVERT $image -thumbnail '240x300^' -gravity center -extent 240x300 thumbnail_$image)
  # combine the frame and the thumbnail
  $($CONVERT $FRAMEPATH thumbnail_$image -gravity center -compose DstOver \
  -composite border_overlaid_$image.png)
  rm thumbnail_$image
  rm $image
done
Comments/fixes/improvements are wellcome
 
Hi,

First post, although I've been a lurker for a while.

I'm just getting in to using Geektool on my new MBP (it wouldn't run on my old MB :( ) and would really like something which works like Bowtie (or one of the iTunes geeklets), but shows the information for my Sonos system.

Since getting my Sonos setup, I don't find myself using iTunes as much, but really like the Bowtie interface.

The Sonos desktop controller is so clunky in comparison and not very :apple:

I've searched through Google and the Sonos forums but don't find any mention of Geektool and Sonos working together. Has anyone got something working which they could share?

Thanks
 
i have finally finished my desktop using this forum for most of my scripting. thanks to you all that have posted scripts :D
 

Attachments

  • Screen Shot 2011-10-30 at 4.47.46 PM.jpg
    Screen Shot 2011-10-30 at 4.47.46 PM.jpg
    265.8 KB · Views: 391
Currency GeekTool Script

Hi, I know this topic has appeared before but I can't seem to get to a satisfactory conclusion.

I'm using the below script for my currency exchanges and all was ok until changing to Lion. Now, it displays as a + or - and a % change.

However, if I change the currency to EURXXX (XXX being whatever currency) then it displays as 1 EUR = XXX

What do I need to change in the script that displays 1 GBP = XXX etc.

Thanks

curl --silent http://www.google.com/finance?q=GBPEUR | grep "span" | sed -e :a -e 's/<[^>]*>//g;//ba' | head -8 | tail -n 5 | sed '/^$/d' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /';
 
Hi, I know this topic has appeared before but I can't seem to get to a satisfactory conclusion.

I'm using the below script for my currency exchanges and all was ok until changing to Lion. Now, it displays as a + or - and a % change.

However, if I change the currency to EURXXX (XXX being whatever currency) then it displays as 1 EUR = XXX

What do I need to change in the script that displays 1 GBP = XXX etc.

Thanks

curl --silent http://www.google.com/finance?q=GBPEUR | grep "span" | sed -e :a -e 's/<[^>]*>//g;//ba' | head -8 | tail -n 5 | sed '/^$/d' | sed -e '$!N;s/\n/ /' -e '$!N;s/\n/ /';

If I'm reading your post correctly, you want the output to just be

1 XXX = 2 YYY

for any currency you provide to either side of the equation? If so, this should work.

Code:
curl --silent http://www.google.com/finance?q=GBPEUR | grep class="bld" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

Disclaimer: I've never used or looked at this Google page before. But the line above works on every combination of USD/EUR/GBP based on how its HTML looks right now.
 
GeekTool Currency

If I'm reading your post correctly, you want the output to just be

1 XXX = 2 YYY

for any currency you provide to either side of the equation? If so, this should work.

Code:
curl --silent http://www.google.com/finance?q=GBPEUR | grep class="bld" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

Disclaimer: I've never used or looked at this Google page before. But the line above works on every combination of USD/EUR/GBP based on how its HTML looks right now.

Absolute Star! Thanks so much, really appreciated!
 
RSS feed question

hello! this is my first post on this thread and i was wondering how i could remove the "&quot;" that appears every time there are quotation marks in an RSS feed using this script when displayed in geektool. thanks!

Code:
URL="feeds.urbandictionary.com/UrbanWordOfTheDay"
maxLength="3000"
start="3"
end="2"

curl --silent "$URL" |
sed -e :a -e '$!N;s/\n//;ta' |
sed -e 's/<title>/\
<title>/g' |
sed -e 's/<\/title>/<\/title>\
/g' |
sed -e 's/<description>/\
<description>/g' |
sed -e 's/<\/description>/<\/description>\
/g' |
grep -E '(title>|description>)' |
sed -n "$start,$"'p' |
sed -e 's/<title>//' |
sed -e 's/<\/title>//' |
sed -e 's/<description>/   /' |
sed -e 's/<\/description>//' |
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/</</g' |
sed -e 's/>/>/g' |
sed -e 's/<[^>]*>//g' |
cut -c 1-$maxLength |
head -$end |
sed G |
fmt
 
All I did was add another sed line in there to replace the html entity with an actual quote:

Code:
URL="feeds.urbandictionary.com/UrbanWordOfTheDay"
maxLength="3000"
start="3"
end="2"

curl --silent "$URL" |
sed -e :a -e '$!N;s/\n//;ta' |
sed -e 's/<title>/\
<title>/g' |
sed -e 's/<\/title>/<\/title>\
/g' |
sed -e 's/<description>/\
<description>/g' |
sed -e 's/<\/description>/<\/description>\
/g' |
grep -E '(title>|description>)' |
sed -n "$start,$"'p' |
sed -e 's/<title>//' |
sed -e 's/<\/title>//' |
sed -e 's/<description>/   /' |
sed -e 's/<\/description>//' |
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/</</g' |
sed -e 's/>/>/g' |
sed -e 's/&quot;/\"/g' |
sed -e 's/<[^>]*>//g' |
cut -c 1-$maxLength |
head -$end |
sed G |
fmt
 
excellent! thank you very much :)

All I did was add another sed line in there to replace the html entity with an actual quote:

Code:
URL="feeds.urbandictionary.com/UrbanWordOfTheDay"
maxLength="3000"
start="3"
end="2"

curl --silent "$URL" |
sed -e :a -e '$!N;s/\n//;ta' |
sed -e 's/<title>/\
<title>/g' |
sed -e 's/<\/title>/<\/title>\
/g' |
sed -e 's/<description>/\
<description>/g' |
sed -e 's/<\/description>/<\/description>\
/g' |
grep -E '(title>|description>)' |
sed -n "$start,$"'p' |
sed -e 's/<title>//' |
sed -e 's/<\/title>//' |
sed -e 's/<description>/   /' |
sed -e 's/<\/description>//' |
sed -e 's/<!\[CDATA\[//g' |
sed -e 's/\]\]>//g' |
sed -e 's/</</g' |
sed -e 's/>/>/g' |
sed -e 's/&quot;/\"/g' |
sed -e 's/<[^>]*>//g' |
cut -c 1-$maxLength |
head -$end |
sed G |
fmt
 
I try to setup evernote with geektool for here.

When i refresh he creates a xml in the temp folder. In the xml they are my notes buy Geektool shows nothing.
Can someone help me?
My script for geektool:
Code:
curl --silent "http://www.evernote.com/shard/s138/pub/........./.........../
notizbuch/rss.jsp?max=25&sort=2&search=" > /tmp/evernote_feed.xml;
python /evernote_feedgrabber.py

OsX Lion 10.7.2
Language: german
Thanks

Sorry for the bad english
 
Problems with remote ssh command

I'm attempting to have a command I can leave running in geektool.

What I want is to run iftop on a remote machine and see the display locally.

It displays properly when run from the command line, but when I insert the command in geektool it only shows

"TOTAL: 0B 0B 0B 0B 0BP"

The command is the standard ssh -t user@host 'iftop -B'

Obviously I'm missing something-just not sure what. Any assistance is appreciated.
 
... and in the end, I have this.

I've spent a little of my spare time in doing this. It has some shell script, some ruby and some of everything you can find in the internet. I'll post everything to my blog (blogs.fcallem.net/bitio).
Captura%2Bde%2Bpantalla%2B2011-11-13%2Ba%2Bla%2528s%2529%2B13.26.03.png
 
Last edited by a moderator:
Can't Control GT

I haven't tweaked anything in quite some time as I like the way things are for the most part, but I'd like to delete a ToDo list as I find I don't use it. When in GT I cannot select the boxes on my desktop in order to delete them. As a matter-or-fact I can't select any boxes to move them around or do any tweaks to anything. Sup?

Thanks for any help.
 
I have the current conditions, the current conditions icon, and the current temperature that's been discussed many times on this thread. The source website for temperature is based on zip code, which pulls the information from the weather station at the local airport. It's great, they function perfectly.

The airport is 20 miles from my place, but recently I've found a personal weather station that is closer, only 6 miles. I'd like to be able to grab that temp off that website for comparison, or at least a (possibly) more accurate estimation for my location.

The closer temperature is on a different website and I don't know enough to be able to write a command to grab that number. Can anyone help?

http://www.weatherlink.com/user/steincabin
 
I try to setup evernote with geektool for here.

When i refresh he creates a xml in the temp folder. In the xml they are my notes buy Geektool shows nothing.
Can someone help me?
My script for geektool:
Code:
curl --silent "http://www.evernote.com/shard/s138/pub/........./.........../
notizbuch/rss.jsp?max=25&sort=2&search=" > /tmp/evernote_feed.xml;
python /evernote_feedgrabber.py

OsX Lion 10.7.2
Language: german
Thanks

Sorry for the bad english

That script is over a year old now. I don't use evernote, I just created the script for another user on this site.

Usually if there is no output displayed, the parser fails to parse the RSS feed. This means that they probably changed the feed on me.
 
I have the current conditions, the current conditions icon, and the current temperature that's been discussed many times on this thread. The source website for temperature is based on zip code, which pulls the information from the weather station at the local airport. It's great, they function perfectly.

The airport is 20 miles from my place, but recently I've found a personal weather station that is closer, only 6 miles. I'd like to be able to grab that temp off that website for comparison, or at least a (possibly) more accurate estimation for my location.

The closer temperature is on a different website and I don't know enough to be able to write a command to grab that number. Can anyone help?

http://www.weatherlink.com/user/steincabin

I'll try to help with this, but that link is 404'ing for me.
 
hey guys - here's my latest. getting a little info overload here, but i've leaner 'groups' that i switch to when i'm, say, not interested in the financials. if anyone wants those codes, by the way:

GOLD futures:
curl http://www.barchart.com/ | grep 'Gold' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tail -1 | sed 's/Gold/GOLD /g' | sed 's/+/ +/g' | sed 's/-/ -/g'

OIL futures:
curl http://www.barchart.com/ | grep 'Oil' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tail -1 | sed 's/Crude Oil/OIL /g' | sed 's/-/ -/g'


Hi. I'm a geektool noob (with a now-crowded desktop pane), and I was wondering if anyone could help with an update to the above commands, which no longer seem to work. I need a wheat futures quote on my desktop, but yahoo finance doesn't seem to quote wheat. Any help is greatly appreciated! :apple:
 
I have the current conditions, the current conditions icon, and the current temperature that's been discussed many times on this thread. The source website for temperature is based on zip code, which pulls the information from the weather station at the local airport. It's great, they function perfectly.

The airport is 20 miles from my place, but recently I've found a personal weather station that is closer, only 6 miles. I'd like to be able to grab that temp off that website for comparison, or at least a (possibly) more accurate estimation for my location.

The closer temperature is on a different website and I don't know enough to be able to write a command to grab that number. Can anyone help?

I wrote this up real quick. It gives you just the current temperature number. If you are looking for anything added to it just let me know...

Code:
curl --silent http://www.weatherlink.com/user/stiencabin/ | grep "glamor_temp" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | sed 's/ //g' | sed 's/°/./g'| cut -d "." -f 1
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.