forked from danichim/redshift-material-gui
/
redshift.js
42 lines (32 loc) · 837 Bytes
/
redshift.js
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
import { exec } from 'child_process';
import { log, info, err } from './logger';
const redshift = (() => {
const start = function starting() {
info("Starting");
exec('redshift -t 2548K:6874K', errorHandler);
};
const stop = function stopping() {
info("Stopping Redshift using '-x' flag.");
exec('redshift -x', errorHandler);
};
const kill = function killing() {
info("Killing Redshift process.");
exec('pkill redshift', errorHandler);
};
const preview = function previewing(setting) {
info(`Previewing with the following settings: ${setting}`);
exec(`redshift -O ${setting}`, errorHandler);
};
return {
start: start,
stop: stop,
kill: kill,
preview: preview
};
})();
function errorHandler(error) {
if(error) {
err(error);
}
}
export default redshift;