-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnight.js
More file actions
36 lines (31 loc) · 723 Bytes
/
Copy pathnight.js
File metadata and controls
36 lines (31 loc) · 723 Bytes
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
function showError(message) {
const app = Application.currentApplication();
app.includeStandardAdditions = true;
app.displayAlert(message);
}
function main() {
const prefName = 'System Preferences';
const anchor = new Application(prefName)
.panes.byId('com.apple.preference.displays')
.anchors.byName('displaysNightShiftTab');
try {
anchor.reveal();
delay(0.5);
} catch (err) {
showError('Please update your macOS');
return;
}
new Application('System Events')
.processes[prefName]
.windows()
.map(w => w.tabGroups[0])
.filter(t => t.checkboxes.length > 0)
.forEach(t => t.checkboxes[0].click());
}
function run(argv) {
try {
main();
} catch (err) {
showError(err.toString());
}
}