Skip to content

Commit a3fdfb3

Browse files
committed
feat(cli): add options to set max temperature and max fan-off temperature
Introduce interactive prompts to set maximum temperature and maximum fan-off temperature from the CLI.
1 parent 0f4aa28 commit a3fdfb3

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

main.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

3-
import ("bufio"; "fmt"; "time"; "os"; "os/exec"; "strings"; "syscall"; w "golang.org/x/sys/windows")
3+
import (
4+
"bufio"; "fmt"; "time"; "os"; "strconv"; "os/exec"; "strings"; "syscall";
5+
w "golang.org/x/sys/windows"
6+
)
47

58
var eventPtr = utf16("Global\\HotAMD")
69

@@ -39,7 +42,12 @@ func runCLI() {
3942
fmt.Print("\n1) ")
4043
if isRunning { fmt.Print("Stop ") } else { fmt.Print("Start ") }
4144
fmt.Println("daemon")
42-
fmt.Println("2) Exit")
45+
46+
fmt.Println("2) Set max temperature")
47+
fmt.Println("3) Set max fan-off temperature")
48+
fmt.Println("4) Exit")
49+
50+
4351
fmt.Print("\n> ")
4452

4553
input, _ := reader.ReadString('\n')
@@ -49,7 +57,29 @@ func runCLI() {
4957
case "1":
5058
if isRunning { stopDaemon() } else { startDaemon() }
5159
time.Sleep(300 * time.Millisecond)
52-
case "2": return
60+
case "2":
61+
fmt.Print("Enter max temperature (°C): ")
62+
input, _ := reader.ReadString('\n')
63+
input = strings.TrimSpace(input)
64+
val, err := strconv.Atoi(input)
65+
if err != nil {
66+
fmt.Println("Invalid input")
67+
} else {
68+
config.MaxTemp = val
69+
saveConfig()
70+
}
71+
case "3":
72+
fmt.Print("Enter max fan-off temperature (°C): ")
73+
input, _ := reader.ReadString('\n')
74+
input = strings.TrimSpace(input)
75+
val, err := strconv.Atoi(input)
76+
if err != nil {
77+
fmt.Println("Invalid input")
78+
} else {
79+
config.MaxFanOffTemp = val
80+
saveConfig()
81+
}
82+
case "4": return
5383
}
5484
}
5585
}

0 commit comments

Comments
 (0)