-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mm
126 lines (95 loc) · 3.21 KB
/
main.mm
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream>
#include <unistd.h>
#include <Foundation/Foundation.h>
#include "simplebrightness/library.h"
// Private frameworks...
#include <CoreBrightness/CBClient.h>
#include <CoreBrightness/CBBlueLightClient.h>
#include <CoreBrightness/CBAdaptationClient.h>
using namespace std;
bool nightshift_set(CBClient *client, BOOL enable){
CBBlueLightClient *blc = [client blueLightClient];
bool success = [blc setEnabled:enable];
return success;
}
bool truetone_set(CBClient *client, BOOL enable){
CBAdaptationClient *adc = [client adaptationClient];
bool success = [adc setEnabled:enable];
return success;
}
void print(const string& msg){
cout << msg << endl;
}
int main() {
cout << "CoreBrightness Test -- By: Angelo DeLuca" << endl << "--" << endl;
// Check whether system supports blue light reduction and adaptation...
bool blr_support = [CBClient supportsBlueLightReduction];
bool tt_support = [CBClient supportsAdaptation];
// Initialize CoreBrightness client.
CBClient *client = [[CBClient alloc] init];
if(blr_support){
print("Your system supports blue light reduction.");
print("Enabling Night Shift in five seconds...");
sleep(5);
bool ns_success = nightshift_set(client, true);
if(ns_success){
print("Night Shift enabled successfully.");
}else{
print("Night Shift enable failed.");
}
sleep(5);
ns_success = nightshift_set(client, false);
if(ns_success){
print("Night Shift disabled successfully.");
}else{
print("Night Shift disable failed.");
}
}else{
print("Your system does not support blue light reduction and the test cannot be completed.");
}
if(tt_support){
print("Your system supports adaptation (which may refer to TrueTone).");
print("Enabling TrueTone in five seconds...");
sleep(5);
bool tt_success = truetone_set(client, true);
if(tt_success){
print("TrueTone enabled successfully.");
}else{
print("TrueTone enable failed.");
}
sleep(5);
tt_success = truetone_set(client, false);
if(tt_success){
print("TrueTone disabled successfully.");
}else{
print("TrueTone disable failed.");
}
}
sleep(4);
print("I will now flash the keyboard five times to test the backlight.");
simplebrightness::setKeyboardBrightness(0);
sleep(1);
simplebrightness::setKeyboardBrightness(1);
sleep(1);
simplebrightness::setKeyboardBrightness(0);
sleep(1);
simplebrightness::setKeyboardBrightness(1);
sleep(1);
simplebrightness::setKeyboardBrightness(0);
sleep(1);
simplebrightness::setKeyboardBrightness(1);
sleep(1);
simplebrightness::setKeyboardBrightness(0);
sleep(1);
simplebrightness::setKeyboardBrightness(1);
sleep(1);
simplebrightness::setKeyboardBrightness(0);
sleep(1);
simplebrightness::setKeyboardBrightness(1);
print("Test complete!");
sleep(3);
print("Resetting to 25% keyboard brightness...");
simplebrightness::setKeyboardBrightness(0.25);
sleep(2);
return 0;
}