File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package main
2+
3+ import ("os" ; "encoding/json" )
4+
5+ type Config struct {
6+ MaxTemp int `json:"maxTemp"`
7+ MaxFanOffTemp int `json:"maxFanOffTemp"`
8+ }
9+
10+ var config = Config {
11+ MaxTemp : 60 ,
12+ MaxFanOffTemp : 40 ,
13+ }
14+
15+ const configFile = "config.json"
16+
17+ func loadConfig () {
18+ data , err := os .ReadFile (configFile )
19+ if err != nil {
20+ saveConfig ()
21+ } else {
22+ json .Unmarshal (data , & config )
23+ }
24+ }
25+
26+ func saveConfig () {
27+ data , _ := json .MarshalIndent (config , "" , " " )
28+ os .WriteFile (configFile , data , 0644 )
29+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ var eventPtr = utf16("Global\\HotAMD")
66
77func main () {
88 initADL ()
9+ loadConfig ()
910 if len (os .Args ) > 1 && os .Args [1 ] == "--daemon" { runDaemon () } else { runCLI () }
1011 destroyADL ()
1112}
Original file line number Diff line number Diff line change 11package main
22
3- import ("unsafe" ; "time" ; w "golang.org/x/sys/windows" )
3+ import ("fmt" ; " unsafe" ; "time" ; w "golang.org/x/sys/windows" )
44
55type ADLTemperature struct {
66 Size int32
@@ -57,10 +57,10 @@ func destroyADL() {
5757func start () {
5858 for {
5959 temp , rpm := readGPU ()
60- if temp > 40 && rpm == 0 {
61- alert ("GPU temperature > 40 °C and fan is not spinning" )
62- } else if temp > 60 {
63- alert ("GPU temperature > 60 °C" )
60+ if int ( temp ) > config . MaxFanOffTemp && rpm == 0 {
61+ alert ("GPU temperature > " + fmt . Sprintf ( "%v" , config . MaxFanOffTemp ) + " °C and fan is not spinning" )
62+ } else if int ( temp ) > config . MaxTemp {
63+ alert ("GPU temperature > " + fmt . Sprintf ( "%v" , config . MaxTemp ) + " °C" )
6464 }
6565 time .Sleep (10 * time .Second )
6666 }
You can’t perform that action at this time.
0 commit comments