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:
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.
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
Last edited: