-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.default.js
50 lines (42 loc) · 1001 Bytes
/
script.default.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
43
44
45
46
47
48
49
50
// %HEADER%
// %INITIALIZATION%
function getTimestamp()
{
return Math.round(Date.now() / 1000)
}
const tempThreshold = 60
const maxCoolSecs = 15
let coolSecsLeft = 0
const refFanSpeed = 50
const tsStart = getTimestamp()
// %GLOBAL_OBJECT%
// %CONSOLE%
// %DEV_PLUGIN_NAME%
console.log(`Device: ${$.dev.name}; plugin: ${$.dev.plugin.name}`)
// %MAIN_FUNCTION%
;()=>{
// %EXAMPLE%
const secsPassed = getTimestamp() - tsStart
if(secsPassed && secsPassed % 10 == 0)
console.log(`The script is running for ${secsPassed} seconds`)
// %DEV_TEMP%
if($.dev.temp > tempThreshold)
{
// %IF_TEMP_HIGH%
coolSecsLeft = maxCoolSecs
}
else
{
// %IF_TEMP_LOW%
if(coolSecsLeft)
coolSecsLeft--
}
// %IF_NEED_COOLING%
if(coolSecsLeft)
{
// %RETURN_FAN_SPEED%
return refFanSpeed + Math.max(0, ($.dev.temp - tempThreshold) / 2)
}
// %LET_GPU_DECIDE%
return $.dev.FAN_SPEED_GPU
}