diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/alarm_stop.sh b/alarm_stop.sh new file mode 100755 index 0000000..c5ea78e --- /dev/null +++ b/alarm_stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +kill `pgrep vlc` +kill `pgrep ffmpeg` +php /opt/SmartAlarm/alarm.php | festival --tts +lame --scale 3 /opt/SmartAlarm/tmp/tmp.mp3 /opt/SmartAlarm/audio_recordings/`date +%Y-%m-%d`.mp3 +rm /opt/SmartAlarm/tmp/tmp.mp3 +php justwave/justwave.cli.php /opt/SmartAlarm/audio_recordings/`datte +%Y-%m-%d`.mp3 wavedir=/opt/SmartAlarm/audio_img/ width=600 height=75 nocache=1 +echo "Alarm finished." diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/alarm_stop.sh b/alarm_stop.sh new file mode 100755 index 0000000..c5ea78e --- /dev/null +++ b/alarm_stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +kill `pgrep vlc` +kill `pgrep ffmpeg` +php /opt/SmartAlarm/alarm.php | festival --tts +lame --scale 3 /opt/SmartAlarm/tmp/tmp.mp3 /opt/SmartAlarm/audio_recordings/`date +%Y-%m-%d`.mp3 +rm /opt/SmartAlarm/tmp/tmp.mp3 +php justwave/justwave.cli.php /opt/SmartAlarm/audio_recordings/`datte +%Y-%m-%d`.mp3 wavedir=/opt/SmartAlarm/audio_img/ width=600 height=75 nocache=1 +echo "Alarm finished." diff --git a/audio_img/.gitkeep b/audio_img/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_img/.gitkeep diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/alarm_stop.sh b/alarm_stop.sh new file mode 100755 index 0000000..c5ea78e --- /dev/null +++ b/alarm_stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +kill `pgrep vlc` +kill `pgrep ffmpeg` +php /opt/SmartAlarm/alarm.php | festival --tts +lame --scale 3 /opt/SmartAlarm/tmp/tmp.mp3 /opt/SmartAlarm/audio_recordings/`date +%Y-%m-%d`.mp3 +rm /opt/SmartAlarm/tmp/tmp.mp3 +php justwave/justwave.cli.php /opt/SmartAlarm/audio_recordings/`datte +%Y-%m-%d`.mp3 wavedir=/opt/SmartAlarm/audio_img/ width=600 height=75 nocache=1 +echo "Alarm finished." diff --git a/audio_img/.gitkeep b/audio_img/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_img/.gitkeep diff --git a/audio_recordings/.gitkeep b/audio_recordings/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_recordings/.gitkeep diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/alarm_stop.sh b/alarm_stop.sh new file mode 100755 index 0000000..c5ea78e --- /dev/null +++ b/alarm_stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +kill `pgrep vlc` +kill `pgrep ffmpeg` +php /opt/SmartAlarm/alarm.php | festival --tts +lame --scale 3 /opt/SmartAlarm/tmp/tmp.mp3 /opt/SmartAlarm/audio_recordings/`date +%Y-%m-%d`.mp3 +rm /opt/SmartAlarm/tmp/tmp.mp3 +php justwave/justwave.cli.php /opt/SmartAlarm/audio_recordings/`datte +%Y-%m-%d`.mp3 wavedir=/opt/SmartAlarm/audio_img/ width=600 height=75 nocache=1 +echo "Alarm finished." diff --git a/audio_img/.gitkeep b/audio_img/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_img/.gitkeep diff --git a/audio_recordings/.gitkeep b/audio_recordings/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_recordings/.gitkeep diff --git a/config.php b/config.php new file mode 100644 index 0000000..c3cbfd5 --- /dev/null +++ b/config.php @@ -0,0 +1,20 @@ +<?php +/*** + * Requires: apt-get install php5-imap + */ +$weatherenabled = 1; +$gmailenabled = 1; +$dateenabled = 1; +$quoteenabled = 1; + +// weather +$city="London"; +$country="UK"; //Two digit country code +$openweatherApiKey = ""; +$weatherurl="http://api.openweathermap.org/data/2.5/weather?q=".$city.",".$country."&units=metric&cnt=7&lang=en&appid=".$openweatherApiKey; +// gmail +$hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; +$username = ''; +$password = ''; + +?> diff --git a/README.md b/README.md index b1edbec..e60caff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ SmartAlarm =============== -Smart alarm clock \ No newline at end of file +Wake up with custom messages and notifications + +Requirements +=============== +festival, php5, php5-imap, alarm of your choice (I use alarm-clock-applet) + + $> apt-get install festival php5 php-imap alarm-clock-applet + $> php5enmod imap + +Installation and Usage +=============== +git clone the repo, update submodules and make executable: + + cd /opt + git pull http://swin.es/g/git/NaN/SmartAlarm.git + cd SmartAlarm + git pull && git submodule init && git submodule update && git submodule status + chmod +x ./alarm.php + +Modify **config.php** to contain your API keys, settings etc. + +Add custom command to your alarm program (alarm-clock-applet) to launch SmartAlarm stop script. eg. + + konsole -e "/opt/SmartAlarm/alarm_stop.sh" + +Add command to launch alarm before sleeping (I use gpodder) so under "podcast"->"preferences" set "audio player" to: + + /opt/SmartAlarm/alarm_start.sh %U + +Features +=============== + * Custom messages + * Gmail number of emails and unread count + * Weather (temp, wind speed, cloud coverage, overview) + * Date and week no. + * Quote of the day + * Record microphone overnight \ No newline at end of file diff --git a/alarm.php b/alarm.php new file mode 100644 index 0000000..96d651c --- /dev/null +++ b/alarm.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +<?php +include('config.php'); + +// quote +$category = "life"; // inspire, management, sports, life, funny, love, art, students + +$tosay = "beep beep beep beep beep?\n + beep beep beep beep beep.\n + wake up, wake up, wake up, wake up, wake up.\n + It's time to start the day!\n"; + +/* Get Weather Data */ +if($weatherenabled == 1){ + $json=file_get_contents($weatherurl); + $data=json_decode($json,true); + + $tosay .= "... weather ...\n"; + $tosay .= "the temperature is ".$data['main']['temp']." degrees outside.\n"; + $tosay .= "the wind is blowing at ".$data['wind']['speed']." miles per hour.\n"; + $tosay .= "clouds cover ".$data['clouds']['all']." percent of the sky.\n"; + $tosay .= "this is best described as ".$data['weather'][0]['description'].".\n"; +} + +if($gmailenabled == 1){ + $mbox = imap_open($hostname,$username,$password)or die("can't connect: " . imap_last_error()); + $status=imap_status($mbox,$hostname,SA_ALL); + if ($status) { + $tosay .= "... email ...\n"; + $tosay .= "there are ".$status->messages." email sin your inbox. ".$status->unseen." are unread.\n"; + } else { + echo "imap_status failed: " . imap_last_error() . "\n"; + } + imap_close($mbox); +} + +if($dateenabled == 1){ + $week = date('W'); + $fulldate = date('l \t\h\e jS \of F Y'); + $tosay .= "... date and time ...\n"; + $tosay .= "today is ".$fulldate.".\n"; + $tosay .= "it is week number ".$week.".\n"; +} + +if($quoteenabled == 1){ + $json=file_get_contents('https://quotes.rest/qod?category='.$category); + $data=json_decode($json,true); + $author = $data['contents']['quotes'][0]['author']; + $quote = $data['contents']['quotes'][0]['quote']; + $tosay .= "... quote of the day ...\n"; + $tosay .= $author." once said... ".$quote.".\n"; +} + +echo $tosay; + +?> diff --git a/alarm_start.sh b/alarm_start.sh new file mode 100755 index 0000000..c518efe --- /dev/null +++ b/alarm_start.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# -ss = seconds to crop from begining, 1800 = 30 min +ffmpeg -f alsa -ac 2 -ar 44100 -i hw:0,0 -acodec libmp3lame -nostdin -ss 1800 /opt/SmartAlarm/tmp/tmp.mp3 & +/usr/bin/vlc --started-from-file "$*" + diff --git a/alarm_stop.sh b/alarm_stop.sh new file mode 100755 index 0000000..c5ea78e --- /dev/null +++ b/alarm_stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash +kill `pgrep vlc` +kill `pgrep ffmpeg` +php /opt/SmartAlarm/alarm.php | festival --tts +lame --scale 3 /opt/SmartAlarm/tmp/tmp.mp3 /opt/SmartAlarm/audio_recordings/`date +%Y-%m-%d`.mp3 +rm /opt/SmartAlarm/tmp/tmp.mp3 +php justwave/justwave.cli.php /opt/SmartAlarm/audio_recordings/`datte +%Y-%m-%d`.mp3 wavedir=/opt/SmartAlarm/audio_img/ width=600 height=75 nocache=1 +echo "Alarm finished." diff --git a/audio_img/.gitkeep b/audio_img/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_img/.gitkeep diff --git a/audio_recordings/.gitkeep b/audio_recordings/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/audio_recordings/.gitkeep diff --git a/config.php b/config.php new file mode 100644 index 0000000..c3cbfd5 --- /dev/null +++ b/config.php @@ -0,0 +1,20 @@ +<?php +/*** + * Requires: apt-get install php5-imap + */ +$weatherenabled = 1; +$gmailenabled = 1; +$dateenabled = 1; +$quoteenabled = 1; + +// weather +$city="London"; +$country="UK"; //Two digit country code +$openweatherApiKey = ""; +$weatherurl="http://api.openweathermap.org/data/2.5/weather?q=".$city.",".$country."&units=metric&cnt=7&lang=en&appid=".$openweatherApiKey; +// gmail +$hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; +$username = ''; +$password = ''; + +?> diff --git a/tmp/.gitkeep b/tmp/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tmp/.gitkeep