-
Notifications
You must be signed in to change notification settings - Fork 22
/
snoozer.php
32 lines (25 loc) · 1.08 KB
/
snoozer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
const IS_ROMONITOR = true;
require_once ("includes/vars.php");
require_once ("includes/functions.php");
$opts = getopt('', ['snooze:']);
prefs::set_pref($opts);
logger::mark("SNOOZE", "Initialising Snooze For Index", prefs::get_pref('snooze'));
prefs::$database = new timers();
$alarm = prefs::$database->get_alarm(prefs::get_pref('snooze'));
prefs::$database->update_snooze_pid_for_alarm(prefs::get_pref('snooze'), getmypid());
prefs::$database->close_database();
prefs::$database = null;
logger::mark("SNOOZE", "Player is",$alarm['Player']);
prefs::set_pref(['currenthost' => $alarm['Player']]);
logger::info('SNOOZE', 'Sleeping For',prefs::get_pref('alarm_snoozetime'),'minutes');
$sleeptime = (int) prefs::get_pref('alarm_snoozetime') * 60;
sleep($sleeptime);
// Update the database now so the UI reads the snooze PID when it reacts
prefs::$database = new timers();
prefs::$database->update_snooze_pid_for_alarm(prefs::get_pref('snooze'), null);
prefs::$database->close_database();
$player = new base_mpd_player();
$player->do_command_list(['play']);
$player->close_mpd_connection();
?>