Initial commit
1 parent cf9b6c1 commit c1bed24152d885c057dbebc950d482a856eba47a
root authored on 7 May 2019
Showing 8 changed files
View
74
README.md
SmartAlarm
===============
 
Smart alarm clock
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
View
57
alarm.php 0 → 100644
#!/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;
 
?>
View
6
alarm_start.sh 0 → 100755
#!/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 "$*"
 
View
9
alarm_stop.sh 0 → 100755
#!/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."
View
0
■■■■■
audio_img/.gitkeep 0 → 100644
View
0
■■■■■
audio_recordings/.gitkeep 0 → 100644
View
config.php 0 → 100644
View
tmp/.gitkeep 0 → 100644
Buy Me A Coffee