-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
53 lines (44 loc) · 1.11 KB
/
main.go
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
package main
import (
"math/rand"
"time"
"gorandomcaps/icon" // Import the icon package
"github.com/getlantern/systray"
)
func main() {
// Start the Caps Lock toggler in a separate goroutine
go runCapsLockToggler()
// Run the systray UI
systray.Run(onReady, nil) // No cleanup needed
}
func onReady() {
// Set the icon and tooltip
systray.SetIcon(icon.Data) // Use the embedded icon data
systray.SetTitle("Alarms")
systray.SetTooltip("Manages notification alarms")
// Add menu options
rebootItem := systray.AddMenuItem("Reboot", "Reboot System")
startOnBootItem := systray.AddMenuItem("Start on Boot", "Enable program to run on startup")
// Handle menu item clicks
go func() {
for {
select {
case <-rebootItem.ClickedCh:
systray.Quit()
case <-startOnBootItem.ClickedCh:
err := enableStartup()
if err != nil {
println("Failed to enable startup:", err)
} else {
println("Program successfully added to startup!")
}
}
}
}()
}
func runCapsLockToggler() {
for range time.Tick(time.Duration(rand.Intn(10)) * time.Minute) {
// Toggle Caps Lock
ToggleCapsLock()
}
}