![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
General Help All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu. |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
A Carafe of Ubuntu
![]() Join Date: Aug 2007
Location: Belgium
Beans: 114
Ubuntu 7.10 Gutsy Gibbon
|
Script to check gmail account with LED notification (Laptop users...)
Here is the script I'm using to check my gmail account automatically and give me a notification by the LED on my laptop, if you don't know how to enable your LED, I refer to the Pedric's Howto (see credits)
Code:
#!/bin/bash
gmail_login="xxxxxx"
gmail_password="xxxxx"
mails="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"
if [ "$mails" -gt "0" ];
then
for ((i = 0; i < 10; i++)) do
echo 1 > /proc/acpi/asus/mled;
sleep 0.8;
echo 0 > /proc/acpi/asus/mled;
sleep 0.5;
done
fi
exit
You also need to create a crontab entry for this to run every time you define: (I'm running it every 5 minutes) Code:
00 * * * * .scripts/gmailLED.sh 05 * * * * .scripts/gmailLED.sh 10 * * * * .scripts/gmailLED.sh 15 * * * * .scripts/gmailLED.sh 20 * * * * .scripts/gmailLED.sh 25 * * * * .scripts/gmailLED.sh 30 * * * * .scripts/gmailLED.sh 35 * * * * .scripts/gmailLED.sh 40 * * * * .scripts/gmailLED.sh 45 * * * * .scripts/gmailLED.sh 50 * * * * .scripts/gmailLED.sh 55 * * * * .scripts/gmailLED.sh - Gmail bash script from dbbolton - Howto: LED-notification by Pedric
__________________
El Belgicano Laptop: Asus M6N, ATI 9600/9700, 512RAM, Intel Mobile 1.66GHz, 60Gb, Dual boot: Ubuntu 7.10 (Soon to become 8.10 Ibex) & Win XP. |
|
|
|
|
|
#2 |
|
午後の紅茶 お願いします
![]() Join Date: Feb 2006
Location: Japan
Beans: 5,738
Ubuntu
|
Re: Script to check gmail account with LED notification (Laptop users...)
Moved to General Help.
__________________
Ubuntu user #7247 :: Linux user #409907
Motho ke motho ka botho :: Buy old, not new :: Keep your old computer :: Things to do with it |
|
|
|
|
|
#3 |
|
100% Pure Ubuntu
![]() Join Date: Feb 2007
Beans: 847
|
Re: Script to check gmail account with LED notification (Laptop users...)
Instead of multiple entries in crontab, use the following code to run every 5 minutues:
Code:
*/5 * * * * .scripts/gmailLED.sh |
|
|
|
|
|
#4 |
|
Day Old Decaf
![]() |
Re: Script to check gmail account with LED notification (Laptop users...)
That script is no good, because it relies on certain hardware.
This should work on any computer. Code:
sudo apt-get install blinkd Code:
#!/bin/bash
gmail_login="XXXX"
gmail_password="XXXX"
mails="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"
if [ "$mails" -gt "0" ];
then
blink --scrolllockled --rate=$mails;
else
blink -s --rate=0;
fi
exit
If you get a lot of mails, you could change the zero in the "if" line to two or three, so that it only bothers you when there are more mails to read. If you're happy with it alerting you of every e-mail, you could simplify the code by removing all the lines in italics in the script. To "snooze" it (tell it to give you another five minutes to get to gmail, type "blink -sr 0". You could make a launcher for that and stick it on your desktop. To tell it to stop annoying you for the rest of the session, kill the daemon. ("sudo killall blinkd") If the flashing doesn't work, make sure that the daemon is running. ("sudo blinkd") Last edited by ChameleonDave; July 4th, 2008 at 12:19 AM.. Reason: grammar |
|
|
|
|
|
#5 |
|
5 Cups of Ubuntu
![]() Join Date: Aug 2005
Location: Portland, OR USA
Beans: 33
Ubuntu 9.04 Jaunty Jackalope
|
Re: Script to check gmail account with LED notification (Laptop users...)
This is one of the coolest things I've ever seen (computer-related, that is).
|
|
|
|
|
|
#6 |
|
Just Give Me the Beans!
![]() |
Re: Script to check gmail account with LED notification (Laptop users...)
This is significantly awesome, but I figured voice would make it better. Here's mine:
Code:
#!/bin/bash echo "Checking for new email"; mailsa="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \ https://name1:password1@mail.google.com/mail/feed/atom \ --no-check-certificate | grep 'fullcount' \ | sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)" echo $mailsa; mailsb="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \ https://name2:password2@mail.google.com/mail/feed/atom \ --no-check-certificate | grep 'fullcount' \ | sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)" echo $mailsb; #blink LEDs if [ "$mailsa" -gt "0" ]; then blink -s -r 5; fi if [ "$mailsb" -gt "0" ]; then blink -c -r 5; fi #speak announcements if [ "$mailsa" -gt "0" ]; then espeak "$mailsa new emails in main account."; fi if [ "$mailsb" -gt "0" ]; then espeak "$mailsb new emails in secondary account."; fi sleep 4; blink; exit Now, i'd like to know, is there any way to make this code more secure, IE not having my password in plain text? |
|
|
|
|
|
#7 | |
|
Dipped in Ubuntu
![]() Join Date: Mar 2009
Location: USA
Beans: 530
Ubuntu 9.10 Karmic Koala
|
Re: Script to check gmail account with LED notification (Laptop users...)
Quote:
Code:
*/5 9-23 * * * .scripts/gmailLED.sh Haven't tested it but it should work.
__________________
100% Microsoft Free Since April 2, 2009 All info is best effort only. While I hope it is correct no warranty is implied. |
|
|
|
|
|
|
#8 |
|
Skinny Soy Caramel Ubuntu
![]() |
Re: Script to check gmail account with LED notification (Laptop users...)
I've been modifying and working on my own version of this script. Here it is. You guys try this out and see what how you like it.
PHP Code:
PHP Code:
PHP Code:
__________________
Linux HowTos and Free Support! http://linuxinovations.blogspot.com/ Green means go, Yellow means faster, Red means don't stop. Last edited by go_beep_yourself; June 20th, 2009 at 04:40 AM.. |
|
|
|
|
|
#9 |
|
Quad Shot of Ubuntu
![]() Join Date: May 2007
Location: Crete, Greece
Beans: 508
|
Re: Script to check gmail account with LED notification (Laptop users...)
Thanks for this thread! This is an amazing idea
|
|
|
|
| Bookmarks |
| Tags |
| gmail, laptop, led, script |
| Thread Tools | |
| Display Modes | |
|
|