diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..435a885 --- /dev/null +++ b/.air.toml @@ -0,0 +1,17 @@ +# Working directory +root = "." + +# The main Go file +main = "main.go" + +bin = "tmp/main.exe" + +# Watching all Go files, excluding certain directories +[build] + cmd = "go build -o ./tmp/main.exe main.go" + include_ext = ["go"] + exclude_dir = ["fe", "panels", "builds"] + +# Restart on file changes +[log] + time = true diff --git a/.gitignore b/.gitignore index b428472..345ff6f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ .env config.js -be/devices/* -be/tmp/ -be/log.txt +devices/* +tmp/ +log.txt + +Macrame.exe public macros/* diff --git a/Macrame.lnk b/Macrame.lnk deleted file mode 100644 index c65f5dc..0000000 Binary files a/Macrame.lnk and /dev/null differ diff --git a/Screenshot 2025-03-08 004134.jpg b/Screenshot 2025-03-08 004134.jpg deleted file mode 100644 index 7ae5098..0000000 Binary files a/Screenshot 2025-03-08 004134.jpg and /dev/null differ diff --git a/be/app/api.go b/app/api.go similarity index 90% rename from be/app/api.go rename to app/api.go index 7f2ebc0..e9c2f84 100644 --- a/be/app/api.go +++ b/app/api.go @@ -1,28 +1,28 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ package app import ( - "be/app/helper" + "macrame/app/helper" "mime" "net/http" "path/filepath" @@ -45,7 +45,7 @@ func ApiCORS(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, *http } func ApiGet(w http.ResponseWriter, r *http.Request) { - root, err := filepath.Abs("../public") + root, err := filepath.Abs("public") if err != nil { MCRMLog("ApiGet Abs Error: ", err) return @@ -96,7 +96,7 @@ func ApiPost(w http.ResponseWriter, r *http.Request) { case "/macro/play": PlayMacro("", w, r) case "/device/server/ip": - GetServerIP(w, r) + ListServerIP(w) case "/device/list": DeviceList(w, r) case "/device/access/check": diff --git a/be/app/device.go b/app/device.go similarity index 91% rename from be/app/device.go rename to app/device.go index 8c83f43..6352e5f 100644 --- a/be/app/device.go +++ b/app/device.go @@ -1,31 +1,31 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ package app import ( - "be/app/helper" - "be/app/structs" "encoding/json" "fmt" + "macrame/app/helper" + "macrame/app/structs" "math/rand" "net" "net/http" @@ -35,11 +35,22 @@ import ( "time" ) -func GetServerIP(w http.ResponseWriter, r *http.Request) { +func ListServerIP(w http.ResponseWriter) { + ip, err := GetServerIp() + + if err != nil { + MCRMLog("GetServerIP err: ", err) + return + } + + json.NewEncoder(w).Encode(ip) +} + +func GetServerIp() (string, error) { ifs, err := net.Interfaces() if err != nil { MCRMLog(err) - return + return "", err } for _, ifi := range ifs { @@ -78,10 +89,11 @@ func GetServerIP(w http.ResponseWriter, r *http.Request) { } // Found a good IP, return it - json.NewEncoder(w).Encode(ip.String()) - return + return ip.String(), nil } } + + return "", fmt.Errorf("No IP found") } func DeviceList(w http.ResponseWriter, r *http.Request) { diff --git a/be/app/helper/api-helper.go b/app/helper/api-helper.go similarity index 90% rename from be/app/helper/api-helper.go rename to app/helper/api-helper.go index 10f1bfb..f88106b 100644 --- a/be/app/helper/api-helper.go +++ b/app/helper/api-helper.go @@ -1,21 +1,21 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -28,8 +28,8 @@ import ( "net/http" "strings" - "be/app/structs" - . "be/app/structs" + "macrame/app/structs" + . "macrame/app/structs" ) func EndpointAccess(w http.ResponseWriter, r *http.Request) (bool, string, error) { diff --git a/be/app/helper/browser-helper.go b/app/helper/browser-helper.go similarity index 100% rename from be/app/helper/browser-helper.go rename to app/helper/browser-helper.go diff --git a/be/app/helper/device-helper.go b/app/helper/device-helper.go similarity index 100% rename from be/app/helper/device-helper.go rename to app/helper/device-helper.go diff --git a/be/app/helper/encrypt-helper.go b/app/helper/encrypt-helper.go similarity index 100% rename from be/app/helper/encrypt-helper.go rename to app/helper/encrypt-helper.go diff --git a/be/app/helper/env-helper.go b/app/helper/env-helper.go similarity index 83% rename from be/app/helper/env-helper.go rename to app/helper/env-helper.go index 848a78b..28af4d4 100644 --- a/be/app/helper/env-helper.go +++ b/app/helper/env-helper.go @@ -1,21 +1,21 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -30,9 +30,10 @@ import ( "strings" ) -var configPath = "../public/config.js" +var configPath = "public/config.js" func EnvGet(key string) string { + if !configFileExists() { CreateConfigFile(configPath) CheckFeDevDir() @@ -64,9 +65,10 @@ func configFileExists() bool { func CheckFeDevDir() { log.Println("Checking FE dev directory...") - _, err := os.Stat("../fe") + _, err := os.Stat("fe") if err != nil { + log.Println("Error checking FE dev directory:", err) return } @@ -74,14 +76,14 @@ func CheckFeDevDir() { } func copyConfigToFe() { - data, err := os.ReadFile("../public/config.js") + data, err := os.ReadFile(configPath) if err != nil { log.Println("Error reading config.js:", err) return } - if err := os.WriteFile("../fe/config.js", data, 0644); err != nil { + if err := os.WriteFile("fe/config.js", data, 0644); err != nil { log.Println("Error writing config.js:", err) } } diff --git a/be/app/helper/macro-helper.go b/app/helper/macro-helper.go similarity index 100% rename from be/app/helper/macro-helper.go rename to app/helper/macro-helper.go diff --git a/app/helper/translation-helper.go b/app/helper/translation-helper.go new file mode 100644 index 0000000..fdcffff --- /dev/null +++ b/app/helper/translation-helper.go @@ -0,0 +1,101 @@ +/* +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can +be created with HTML and CSS. + +Copyright (C) 2025 Jesse Malotaux + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +package helper + +import ( + "strings" +) + +var translations = map[string]string{ + "ArrowUp": "up", + "ArrowDown": "down", + "ArrowRight": "right", + "ArrowLeft": "left", + "Meta": "cmd", + "MetaLeft": "lcmd", + "MetaRight": "rcmd", + "Alt": "alt", + "AltLeft": "lalt", + "AltRight": "ralt", + "Control": "ctrl", + "ControlLeft": "lctrl", + "ControlRight": "rctrl", + "Shift": "shift", + "ShiftLeft": "lshift", + "ShiftRight": "rshift", + "AudioVolumeMute": "audio_mute", + "AudioVolumeDown": "audio_vol_down", + "AudioVolumeUp": "audio_vol_up", + "MediaTrackPrevious": "audio_prev", + "MediaTrackNext": "audio_next", + "MediaPlayPause": "audio_play|audio_pause", + "Numpad0": "num0", + "Numpad1": "num1", + "Numpad2": "num2", + "Numpad3": "num3", + "Numpad4": "num4", + "Numpad5": "num5", + "Numpad6": "num6", + "Numpad7": "num7", + "Numpad8": "num8", + "Numpad9": "num9", + "NumLock": "num_lock", + "NumpadDecimal": "num.", + "NumpadAdd": "num+", + "NumpadSubtract": "num-", + "NumpadMultiply": "num*", + "NumpadDivide": "num/", + "NumpadEnter": "num_enter", + "Clear": "num_clear", + "BracketLeft": "[", + "BracketRight": "]", + "Quote": "'", + "Semicolon": ";", + "Backquote": "`", + "Backslash": "\\", + "IntlBackslash": "\\", + "Slash": "/", + "Comma": ",", + "Period": ".", + "Equal": "=", + "Minus": "-", +} + +func Translate(code string) string { + if val, ok := translations[code]; ok { + return val + } + return strings.ToLower(code) +} + +func ReverseTranslate(name string) string { + if name == "\\" { + return "Backslash" + } + + for key, value := range translations { + if value == name { + return key + } + } + return name +} diff --git a/be/app/log.go b/app/log.go similarity index 80% rename from be/app/log.go rename to app/log.go index 894d1da..db662ed 100644 --- a/be/app/log.go +++ b/app/log.go @@ -1,21 +1,21 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ diff --git a/be/app/macro.go b/app/macro.go similarity index 87% rename from be/app/macro.go rename to app/macro.go index 0b9f254..5dff9e0 100644 --- a/be/app/macro.go +++ b/app/macro.go @@ -1,21 +1,21 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -31,8 +31,8 @@ import ( "path/filepath" "strings" - "be/app/helper" - "be/app/structs" + "macrame/app/helper" + "macrame/app/structs" ) func CheckMacro(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func CheckMacro(w http.ResponseWriter, r *http.Request) { var filename = helper.FormatMacroFileName(req.Macro) - macroFile, err := helper.ReadMacroFile(fmt.Sprintf("../macros/%s.json", filename)) + macroFile, err := helper.ReadMacroFile(fmt.Sprintf("macros/%s.json", filename)) if macroFile != nil && err == nil { json.NewEncoder(w).Encode(true) @@ -85,7 +85,7 @@ func SaveMacro(w http.ResponseWriter, r *http.Request) { return } - err = os.WriteFile("../macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644) + err = os.WriteFile("macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644) if err != nil { MCRMLog("SaveMacro WriteFile Error: ", err) return @@ -117,7 +117,7 @@ func simplifyMacro(step structs.Step) map[string]interface{} { } func ListMacros(w http.ResponseWriter, r *http.Request) { - dir := "../macros" + dir := "macros" files, err := os.ReadDir(dir) if err != nil { MCRMLog("ListMacros ReadDir Error: ", err) @@ -154,7 +154,7 @@ func DeleteMacro(w http.ResponseWriter, r *http.Request) { var filename = helper.FormatMacroFileName(req.Macro) - err = os.Remove("../macros/" + filename + ".json") + err = os.Remove("macros/" + filename + ".json") if err != nil { MCRMLog("DeleteMacro Remove Error: ", err) @@ -180,7 +180,7 @@ func PlayMacro(data string, w http.ResponseWriter, r *http.Request) { MCRMLog("Playing Macro: ", macro) var filename = helper.FormatMacroFileName(macro) - var filepath = fmt.Sprintf("../macros/%s.json", filename) + var filepath = fmt.Sprintf("macros/%s.json", filename) macroFile, err := helper.ReadMacroFile(filepath) if err != nil { @@ -208,7 +208,7 @@ func OpenMacro(w http.ResponseWriter, r *http.Request) { return } - macroFile, err := helper.ReadMacroFile(fmt.Sprintf("../macros/%s.json", req.Macro)) + macroFile, err := helper.ReadMacroFile(fmt.Sprintf("macros/%s.json", req.Macro)) if err != nil { MCRMLog("OpenMacro ReadMacroFile Error: ", err) diff --git a/be/app/panel.go b/app/panel.go similarity index 85% rename from be/app/panel.go rename to app/panel.go index e642ce4..9c4a15f 100644 --- a/be/app/panel.go +++ b/app/panel.go @@ -1,38 +1,38 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ package app import ( - "be/app/helper" - "be/app/structs" "encoding/base64" "encoding/json" + "macrame/app/helper" + "macrame/app/structs" "net/http" "os" "strings" ) func PanelList(w http.ResponseWriter, r *http.Request) { - panelDirs, err := os.ReadDir("../panels") + panelDirs, err := os.ReadDir("panels") if err != nil { MCRMLog("PanelList ReadDir Error: ", err) json.NewEncoder(w).Encode(false) @@ -59,7 +59,7 @@ func PanelList(w http.ResponseWriter, r *http.Request) { func getPanelInfo(dirname string) structs.PanelInfo { var panelInfo structs.PanelInfo - jsonFile, err := os.ReadFile("../panels/" + dirname + "/panel.json") + jsonFile, err := os.ReadFile("panels/" + dirname + "/panel.json") if err != nil { panelInfo.Name = strings.Replace(dirname, "_", " ", -1) @@ -86,7 +86,7 @@ func getPanelThumb(dirname string) string { for _, ext := range extensions { filename := "thumbnail" + ext - file, err := os.Open("../panels/" + dirname + "/" + filename) + file, err := os.Open("panels/" + dirname + "/" + filename) if err != nil { MCRMLog("getPanelThumb Open Error: ", err) continue @@ -100,8 +100,8 @@ func getPanelThumb(dirname string) string { } func getPanelCode(dirname string) (html string, css string) { - htmlBytes, _ := os.ReadFile("../panels/" + dirname + "/index.html") - cssBytes, _ := os.ReadFile("../panels/" + dirname + "/output.css") + htmlBytes, _ := os.ReadFile("panels/" + dirname + "/index.html") + cssBytes, _ := os.ReadFile("panels/" + dirname + "/output.css") return string(htmlBytes), string(cssBytes) } @@ -153,7 +153,7 @@ func SavePanelJSON(w http.ResponseWriter, r *http.Request) { return } - filePath := "../panels/" + req.Dir + "/panel.json" + filePath := "panels/" + req.Dir + "/panel.json" req.Dir = "" diff --git a/be/app/structs/api-struct.go b/app/structs/api-struct.go similarity index 100% rename from be/app/structs/api-struct.go rename to app/structs/api-struct.go diff --git a/be/app/structs/device-struct.go b/app/structs/device-struct.go similarity index 100% rename from be/app/structs/device-struct.go rename to app/structs/device-struct.go diff --git a/be/app/structs/macro-struct.go b/app/structs/macro-struct.go similarity index 100% rename from be/app/structs/macro-struct.go rename to app/structs/macro-struct.go diff --git a/be/app/structs/panel-struct.go b/app/structs/panel-struct.go similarity index 100% rename from be/app/structs/panel-struct.go rename to app/structs/panel-struct.go diff --git a/app/systray.go b/app/systray.go new file mode 100644 index 0000000..2c4d819 --- /dev/null +++ b/app/systray.go @@ -0,0 +1,64 @@ +package app + +import ( + "macrame/app/helper" + "os" + + "github.com/getlantern/systray" +) + +func InitSystray() { + go func() { + systray.Run(OnReady, OnExit) + }() +} + +func OnReady() { + systray.SetIcon(getIcon("favicon.ico")) + systray.SetTitle("Macrame") + systray.SetTooltip("Macrame - Server") + + ip, err := GetServerIp() + + if err == nil { + systray.AddMenuItem("IP: "+ip+":"+helper.EnvGet("MCRM__PORT"), "Server IP") + } + + systray.AddSeparator() + + addMCRMItem("Dashboard", "/") + addMCRMItem("Panels", "/panels") + addMCRMItem("Macros", "/macros") + addMCRMItem("Devices", "/devices") + + systray.AddSeparator() + + mQuit := systray.AddMenuItem("Quit Macrame", "Quit Macrame") + go func() { + <-mQuit.ClickedCh + os.Exit(0) + }() +} + +func addMCRMItem(name, urlPath string) { + m := systray.AddMenuItem(name, name) + + go func() { + <-m.ClickedCh + helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT") + urlPath) + }() +} + +func OnExit() { + systray.Quit() +} + +func getIcon(path string) []byte { + icon, err := os.ReadFile(path) + + if err != nil { + MCRMLog("getIcon Error: ", err) + } + + return icon +} diff --git a/be/.air.toml b/be/.air.toml deleted file mode 100644 index 6b2c951..0000000 --- a/be/.air.toml +++ /dev/null @@ -1,52 +0,0 @@ -root = "." -testdata_dir = "testdata" -tmp_dir = "tmp" - -[build] - args_bin = [] - bin = "tmp\\main.exe" - cmd = "go build -o ./tmp/main.exe ." - delay = 1000 - exclude_dir = ["assets", "tmp", "vendor", "testdata"] - exclude_file = [] - exclude_regex = ["_test.go"] - exclude_unchanged = false - follow_symlink = false - full_bin = "" - include_dir = [] - include_ext = ["go", "tpl", "tmpl", "html"] - include_file = [] - kill_delay = "0s" - log = "build-errors.log" - poll = false - poll_interval = 0 - post_cmd = [] - pre_cmd = [] - rerun = false - rerun_delay = 500 - send_interrupt = false - stop_on_error = false - -[color] - app = "" - build = "yellow" - main = "magenta" - runner = "green" - watcher = "cyan" - -[log] - main_only = false - silent = false - time = false - -[misc] - clean_on_exit = false - -[proxy] - app_port = 0 - enabled = false - proxy_port = 0 - -[screen] - clear_on_rebuild = false - keep_scroll = true diff --git a/be/Macrame.exe b/be/Macrame.exe deleted file mode 100644 index 297348f..0000000 Binary files a/be/Macrame.exe and /dev/null differ diff --git a/be/Setup.exe b/be/Setup.exe deleted file mode 100644 index bbc0315..0000000 Binary files a/be/Setup.exe and /dev/null differ diff --git a/be/app/helper/translation-helper.go b/be/app/helper/translation-helper.go deleted file mode 100644 index 2bb9983..0000000 --- a/be/app/helper/translation-helper.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can -be created with HTML and CSS. - -Copyright (C) 2025 Jesse Malotaux - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -package helper - -import ( - "strings" -) - -var translations = map[string]string{ - "ArrowUp": "up", - "ArrowDown": "down", - "ArrowRight": "right", - "ArrowLeft": "left", - "Meta": "cmd", - "MetaLeft": "lcmd", - "MetaRight": "rcmd", - "Alt": "alt", - "AltLeft": "lalt", - "AltRight": "ralt", - "Control": "ctrl", - "ControlLeft": "lctrl", - "ControlRight": "rctrl", - "Shift": "shift", - "ShiftLeft": "lshift", - "ShiftRight": "rshift", - "AudioVolumeMute": "audio_mute", - "AudioVolumeDown": "audio_vol_down", - "AudioVolumeUp": "audio_vol_up", - "MediaTrackPrevious": "audio_prev", - "MediaTrackNext": "audio_next", - "MediaPlayPause": "audio_play|audio_pause", - "Numpad0": "num0", - "Numpad1": "num1", - "Numpad2": "num2", - "Numpad3": "num3", - "Numpad4": "num4", - "Numpad5": "num5", - "Numpad6": "num6", - "Numpad7": "num7", - "Numpad8": "num8", - "Numpad9": "num9", - "NumLock": "num_lock", - "NumpadDecimal": "num.", - "NumpadAdd": "num+", - "NumpadSubtract": "num-", - "NumpadMultiply": "num*", - "NumpadDivide": "num/", - "NumpadEnter": "num_enter", - "Clear": "num_clear", - "BracketLeft": "[", - "BracketRight": "]", - "Quote": "'", - "Semicolon": ";", - "Backquote": "`", - "Backslash": "\", - "IntlBackslash": "\", - "Slash": "/", - "Comma": ",", - "Period": ".", - "Equal": "=", - "Minus": "-", -} - -func Translate(code string) string { - if val, ok := translations[code]; ok { - return val - } - return strings.ToLower(code) -} - -func ReverseTranslate(name string) string { - if name == "\" { - return "Backslash" - } - - for key, value := range translations { - if value == name { - return key - } - } - return name -} - -// func Translate(code string) string { -// translations := map[string]string{ -// "ArrowUp": "up", -// "ArrowDown": "down", -// "ArrowRight": "right", -// "ArrowLeft": "left", -// "Meta": "cmd", -// "MetaLeft": "lcmd", -// "MetaRight": "rcmd", -// "Alt": "alt", -// "AltLeft": "lalt", -// "AltRight": "ralt", -// "Control": "ctrl", -// "ControlLeft": "lctrl", -// "ControlRight": "rctrl", -// "Shift": "shift", -// "ShiftLeft": "lshift", -// "ShiftRight": "rshift", -// "AudioVolumeMute": "audio_mute", -// "AudioVolumeDown": "audio_vol_down", -// "AudioVolumeUp": "audio_vol_up", -// "MediaTrackPrevious": "audio_prev", -// "MediaTrackNext": "audio_next", -// "MediaPlayPause": "audio_play|audio_pause", -// "Numpad0": "num0", -// "Numpad1": "num1", -// "Numpad2": "num2", -// "Numpad3": "num3", -// "Numpad4": "num4", -// "Numpad5": "num5", -// "Numpad6": "num6", -// "Numpad7": "num7", -// "Numpad8": "num8", -// "Numpad9": "num9", -// "NumLock": "num_lock", -// "NumpadDecimal": "num.", -// "NumpadAdd": "num+", -// "NumpadSubtract": "num-", -// "NumpadMultiply": "num*", -// "NumpadDivide": "num/", -// "NumpadEnter": "num_enter", -// "Clear": "num_clear", -// "BracketLeft": "[", -// "BracketRight": "]", -// "Quote": "'", -// "Semicolon": ";", -// "Backquote": "`", -// "Backslash": "\", -// "IntlBackslash": "\", -// "Slash": "/", -// "Comma": ",", -// "Period": ".", -// "Equal": "=", -// "Minus": "-", -// } - -// if translations[code] == "" { -// return strings.ToLower(code) -// } - -// return translations[code] -// } - -// Redundant translation because tolower can be used -// "Backspace": "backspace", -// "Delete": "delete", -// "Enter": "enter", -// "Tab": "tab", -// "Escape": "esc", -// "Home": "home", -// "End": "end", -// "PageUp": "pageup", -// "PageDown": "pagedown", -// "F1": "f1", -// "F2": "f2", -// "F3": "f3", -// "F4": "f4", -// "F5": "f5", -// "F6": "f6", -// "F7": "f7", -// "F8": "f8", -// "F9": "f9", -// "F10": "f10", -// "F11": "f11", -// "F12": "f12", -// "F13": "f13", -// "F14": "f14", -// "F15": "f15", -// "F16": "f16", -// "F17": "f17", -// "F18": "f18", -// "F19": "f19", -// "F20": "f20", -// "F21": "f21", -// "F22": "f22", -// "F23": "f23", -// "F24": "f24", -// "CapsLock": "capslock", -// "Space": "space", -// "PrintScreen": "printscreen", -// "Insert": "insert", diff --git a/be/main.exe b/be/main.exe deleted file mode 100644 index d0d3fe6..0000000 Binary files a/be/main.exe and /dev/null differ diff --git a/be/setup/setup.go b/be/setup/setup.go deleted file mode 100644 index 5ca5505..0000000 --- a/be/setup/setup.go +++ /dev/null @@ -1,31 +0,0 @@ -/* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can -be created with HTML and CSS. - -Copyright (C) 2025 Jesse Malotaux - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -package main - -import "be/app/helper" - -func main() { - helper.CreateConfigFile("../public/config.js") - helper.CheckFeDevDir() - - return -} diff --git a/build.sh b/build.sh index 604a868..65eb876 100644 --- a/build.sh +++ b/build.sh @@ -4,32 +4,30 @@ BUILD_DIR="Macrame_$(date +'%m%d%H%M%S')" # Build the Go application -cd be -go build -o Macrame.exe main.go -go build -o Setup.exe setup/setup.go +go build -ldflags "-H=windowsgui" -o Macrame.exe main.go # Build the frontend -cd ../fe +cd fe npm run build cd ../builds # Create the new build directory mkdir $BUILD_DIR -mkdir $BUILD_DIR/be mkdir $BUILD_DIR/macros mkdir $BUILD_DIR/panels +mkdir $BUILD_DIR/panels/test_panel mkdir $BUILD_DIR/public +mkdir $BUILD_DIR/public/assets # Move the generated files to the new build directory -cp ../be/Macrame.exe $BUILD_DIR/be/Macrame.exe -cp ../be/Setup.exe $BUILD_DIR/be/Setup.exe -cp -r ../macros/* $BUILD_DIR/macros/ -cp -r ../panels/* $BUILD_DIR/panels/ +cp ../Macrame.exe $BUILD_DIR/Macrame.exe +cp ../favicon.ico $BUILD_DIR/favicon.ico +find ../macros -type f ! -name 'ED-*' -exec cp --parents {} "$BUILD_DIR/macros/" \; +cp -r ../panels/test_panel/* $BUILD_DIR/panels/test_panel/ mv ../public/* $BUILD_DIR/public/ -cp ../install.bat $BUILD_DIR/install.bat -cp ../Macrame.lnk $BUILD_DIR/Macrame.lnk +# cp ../install.bat $BUILD_DIR/install.bat powershell -Command "Compress-Archive -Path $BUILD_DIR/* -DestinationPath $BUILD_DIR.zip -Force" diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..a9a8c24 Binary files /dev/null and b/favicon.ico differ diff --git a/fe/src/views/DashboardView.vue b/fe/src/views/DashboardView.vue index 44bd5b0..2b614cc 100644 --- a/fe/src/views/DashboardView.vue +++ b/fe/src/views/DashboardView.vue @@ -34,8 +34,15 @@ along with this program. If not, see .

About Macrame

-

Macrame is an open-source application designed to turn any device into a customizable button panel. Whether you're optimizing your workflow or enhancing your gaming experience, Macrame makes it simple to create and link macros to your button panels.

-

For more information, including details on licensing, visit https://macrame.github.io

+

+ Macrame is an open-source application designed to turn any device into a customizable + button panel. Whether you're optimizing your workflow or enhancing your gaming experience, + Macrame makes it simple to create and link macros to your button panels. +

+

+ For more information, including details on licensing, visit + https://macrame.github.io +

diff --git a/be/go.mod b/go.mod similarity index 67% rename from be/go.mod rename to go.mod index c22028b..369a50c 100644 --- a/be/go.mod +++ b/go.mod @@ -1,14 +1,24 @@ -module be +module macrame -go 1.24.0 +go 1.24.1 -require github.com/go-vgo/robotgo v0.110.7 +require ( + github.com/getlantern/systray v1.2.2 + github.com/go-vgo/robotgo v0.110.7 +) require ( github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect github.com/ebitengine/purego v0.8.2 // indirect github.com/gen2brain/shm v0.1.1 // indirect + github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect + github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect + github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect + github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect + github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect + github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/go-stack/stack v1.8.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/jezek/xgb v1.1.1 // indirect github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c // indirect @@ -16,6 +26,7 @@ require ( github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect github.com/otiai10/gosseract v2.2.1+incompatible // indirect github.com/otiai10/mint v1.6.3 // indirect + github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/robotn/xgb v0.10.0 // indirect github.com/robotn/xgbutil v0.10.0 // indirect diff --git a/be/go.sum b/go.sum similarity index 73% rename from be/go.sum rename to go.sum index 9c09ecb..eca718f 100644 --- a/be/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298/go.mod h1:D+QujdIlUNfa0igpNMk6UIvlb6C252URs4yupRUV4lQ= github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966/go.mod h1:Mid70uvE93zn9wgF92A/r5ixgnvX8Lh68fxp9KQBaI0= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e h1:L+XrFvD0vBIBm+Wf9sFN6aU395t7JROoai0qXZraA4U= @@ -8,9 +9,25 @@ github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/gen2brain/shm v0.1.1 h1:1cTVA5qcsUFixnDHl14TmRoxgfWEEZlTezpUj1vm5uQ= github.com/gen2brain/shm v0.1.1/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA= +github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4= +github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY= +github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So= +github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A= +github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 h1:guBYzEaLz0Vfc/jv0czrr2z7qyzTOGC9hiQ0VC+hKjk= +github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7/go.mod h1:zx/1xUUeYPy3Pcmet8OSXLbF47l+3y6hIPpyLWoR9oc= +github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0= +github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o= +github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc= +github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA= +github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA= +github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= +github.com/getlantern/systray v1.2.2 h1:dCEHtfmvkJG7HZ8lS/sLklTH4RKUcIsKrAD9sThoEBE= +github.com/getlantern/systray v1.2.2/go.mod h1:pXFOI1wwqwYXEhLPm9ZGjS2u/vVELeIgNMY5HvhHhcE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= +github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-vgo/robotgo v0.110.7 h1:4scqQrJOBHoFCfcMROYEVFBxHvB3nF/UN6DWoRIFzBE= github.com/go-vgo/robotgo v0.110.7/go.mod h1:eBUjTHY1HYjzdi1+UWJUbxB+b9gE+l4Ei7vQU/9SnLw= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= @@ -23,6 +40,7 @@ github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c h1:1IlzDla/ZATV github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ= github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0= github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= +github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= @@ -31,6 +49,8 @@ github.com/otiai10/gosseract v2.2.1+incompatible h1:Ry5ltVdpdp4LAa2bMjsSJH34XHVO github.com/otiai10/gosseract v2.2.1+incompatible/go.mod h1:XrzWItCzCpFRZ35n3YtVTgq5bLAhFIkascoRo8G32QE= github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs= github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= +github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= +github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= @@ -42,6 +62,9 @@ github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU= github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs= github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI= +github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tailscale/win v0.0.0-20250213223159-5992cb43ca35 h1:wAZbkTZkqDzWsqxPh2qkBd3KvFU7tcxV0BP0Rnhkxog= @@ -74,5 +97,6 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/install.bat b/install.bat deleted file mode 100644 index 72b79f7..0000000 --- a/install.bat +++ /dev/null @@ -1,32 +0,0 @@ -@echo off - -set ruleName="Macrame LAN Access" -set exePath=%~dp0be\Macrame.exe - -:: Check if rule exists -netsh advfirewall firewall show rule name=%ruleName% >nul 2>&1 -if %errorlevel%==1 ( - netsh advfirewall firewall add rule name=%ruleName% dir=in action=allow program=%exePath% protocol=tcp profile=private enabled=true - echo Firewall rule '%ruleName%' added for %exePath% -) else ( - echo Firewall rule '%ruleName%' already exists -) - -:: Navigate to the "be" directory -cd /d "%~dp0be" - -echo Moved to Backend directory - -:: Run setup.exe to generate configuration and necessary files -start /wait Setup.exe - -:: Run Caddy to generate certificates and serve content -:: start /wait caddy.exe start --config CaddyFile - -:: taskkill /f /im caddy.exe - -:: Now start macrame.exe -start Macrame.exe - -:: End of script -exit \ No newline at end of file diff --git a/be/main.go b/main.go similarity index 74% rename from be/main.go rename to main.go index 383340c..fcbdd69 100644 --- a/be/main.go +++ b/main.go @@ -1,21 +1,21 @@ /* -Macrame is a program that enables the user to create keyboard macros and button panels. -The macros are saved as simple JSON files and can be linked to the button panels. The panels can +Macrame is a program that enables the user to create keyboard macros and button panels. +The macros are saved as simple JSON files and can be linked to the button panels. The panels can be created with HTML and CSS. Copyright (C) 2025 Jesse Malotaux -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -You should have received a copy of the GNU General Public License +You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -25,16 +25,15 @@ import ( "log" "net/http" "os" - "strings" - "be/app" - "be/app/helper" + "macrame/app" + "macrame/app/helper" ) func main() { app.MCRMLogInit() - switchToBeDir() + switchDir() if helper.EnvGet("MCRM__PORT") == "" { app.MCRMLog("Error: MCRM__PORT is not set") @@ -48,20 +47,19 @@ func main() { app.MCRMLog("Listening on http://localhost:" + helper.EnvGet("MCRM__PORT")) + app.InitSystray() + app.MCRMLog(http.ListenAndServe(":"+helper.EnvGet("MCRM__PORT"), nil)) } -func switchToBeDir() { +func switchDir() { cwd, err := os.Getwd() + if err != nil { log.Fatal(err) } - if !strings.HasSuffix(cwd, "be") { - err := os.Chdir("be") - if err != nil { - log.Fatal(err) - } - } + + log.Println(cwd) } func apiInit(w http.ResponseWriter, r *http.Request) {