-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
91 lines (80 loc) · 2.4 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"github.com/getlantern/systray"
"github.com/tech-thinker/stikky/menu"
)
func main() {
runSystray() // Start the systray in a separate goroutine
}
func runSystray() {
systray.Run(menu.OnReady, menu.OnExit)
}
// func onReady() {
// // Set the tray icon
// systray.SetIcon(getIcon("icon/icon.png")) // Replace with your icon path
// // systray.SetIcon(theme.FyneLogo().Content())
// // Set the tray title and tooltip
// systray.SetTitle("Stikky")
// systray.SetTooltip("Simple data management app.")
// // Add menu items
// mOpen := systray.AddMenuItem("Open App", "Open the main application")
// mSave := systray.AddMenuItem("Save Context", "Save from context.")
// mSetContext := systray.AddMenuItem("Set Context", "Set from context.")
// mQuit := systray.AddMenuItem("Quit", "Quit the application")
// // Example dynamic submenu items
// subMenuItems := []string{"Item 1", "Item 2", "Item 3"}
// // Create a submenu
// subMenu := systray.AddMenuItem("Dynamic Submenu", "A submenu with dynamic items")
// for _, item := range subMenuItems {
// subItem := subMenu.AddSubMenuItem(item, fmt.Sprintf("Action for %s", item))
// go func(item string) {
// for {
// select {
// case <-subItem.ClickedCh:
// // Action to perform when the submenu item is clicked
// fmt.Printf("Clicked on %s\n", item)
// subMenu.AddSubMenuItem("Another", "Another item")
// }
// }
// }(item)
// }
// // Handle menu item clicks
// go func() {
// for {
// select {
// case <-mOpen.ClickedCh:
// // Open app logic (e.g., bring Fyne app window to the front)
// // Custom logic can go here
// // Example: Logging
// println("Open App clicked!")
// case <-mSave.ClickedCh:
// content, _ := clipboard.ReadAll()
// fmt.Println(content)
// case <-mSetContext.ClickedCh:
// clipboard.WriteAll("This is new context!")
// case <-mQuit.ClickedCh:
// systray.Quit()
// os.Exit(0)
// }
// }
// }()
// go func() {
// for {
// date := time.Now().String()
// systray.SetTitle(date)
// time.Sleep(1 * time.Second)
// }
// }()
// }
// func onExit() {
// // Cleanup logic when the tray icon is removed
// println("Systray exiting...")
// }
// // getIcon reads an icon file and returns its bytes
// func getIcon(filePath string) []byte {
// data, err := os.ReadFile(filePath)
// if err != nil {
// panic(err)
// }
// return data
// }