-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.php
60 lines (47 loc) · 1.25 KB
/
service.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* @author Jefferson González
* @license MIT
* @link https://github.com/jgmdev/bluecontrol Source code.
*/
require "src/Autoloader.php";
require "vendor/autoload.php";
use BlueControl\Util;
use BlueControl\XRandR;
use BlueControl\Settings;
XRandR::init();
$settings = new Settings("BlueControl");
Util::setDefaults($settings);
// Get/Set timezone
$timezone = $settings->get("timezone", "UTC");
date_default_timezone_set($timezone);
// Get current temperature
if(($value = $settings->get("current_temperature")) != "")
{
XRandR::setTemperature(floatval($value));
}
// Check if automatic cycling is enabled
$auto = $settings->get("automatic", "0");
$auto = $auto == "" ? "0" : $auto;
while(true)
{
if($auto == "1")
{
XRandR::init();
$current_temp = floatval(
$settings->get("current_temperature", "4000")
);
$new_temp = floatval(
$settings->getFromSection(
"time_day",
Util::getDayPeriod()
)
);
if($current_temp != $new_temp)
{
$settings->set("current_temperature", $new_temp);
XRandR::setTemperatureGradually($current_temp, $new_temp);
}
}
sleep(60 * 10); // Run every 10 minutes
}