Created
June 27, 2011 19:29
-
-
Save smasty/1049607 to your computer and use it in GitHub Desktop.
Keyboard LED Gmail checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/** | |
* Checks your GMail for unread messages and lets your keyboard LED diod blink if there are some. | |
* | |
* (c) Martin Srank (http://smasty.net) | |
* Licensed under the MIT License - http://opensource.org/licenses/mit-license | |
* Use at your own risk. Tested on Debian Squeeze. | |
*/ | |
// Gmail credentials | |
$user = 'username'; | |
$pswd = 'password'; | |
// Config options | |
$interval = 300; // Interval for checking e-mail state (in seconds) | |
$ledID = '3'; // Keyboard LED ID | |
$blinkCount = 8; // Number of LED blinks | |
$blinkSpeed = 0.2 // LED blink speed (in seconds) | |
while(true){ | |
$atom = file_get_contents("https://$user:[email protected]/mail/feed/atom"); | |
if(preg_match('~\<fullcount\>(\d+)\<\/fullcount\>~i', $atom, $match) && $match[1] > 0){ | |
for($i = 0; $i < $blinkCount; $i++){ | |
`xset -led $ledID`; | |
usleep($blinkSpeed * 1e6); | |
`xset led $ledID`; | |
usleep($blinkSpeed * 1e6); | |
} | |
} | |
sleep($interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment