Added support for remote0

This commit is contained in:
mikx
2023-10-31 20:16:41 -04:00
commit 5c6e496688
88 changed files with 7833 additions and 0 deletions

31
cmd/hwinfo-plugin/main.go Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"log"
"github.com/hashicorp/go-plugin"
hwinfoplugin "github.com/shayne/hwinfo-streamdeck/internal/hwinfo/plugin"
hwsensorsservice "github.com/shayne/hwinfo-streamdeck/pkg/service"
)
func main() {
service := hwinfoplugin.StartService()
go func() {
for {
err := service.Recv()
if err != nil {
log.Printf("service recv failed: %v\n", err)
}
}
}()
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: hwsensorsservice.Handshake,
Plugins: map[string]plugin.Plugin{
"hwinfoplugin": &hwsensorsservice.HardwareServicePlugin{Impl: &hwinfoplugin.Plugin{Service: service}},
},
// A non-nil value here enables gRPC serving for this plugin...
GRPCServer: plugin.DefaultGRPCServer,
})
}

View File

@@ -0,0 +1,46 @@
package main
import (
"encoding/json"
"flag"
"log"
"os"
"path/filepath"
)
var port = flag.String("port", "", "The port that should be used to create the WebSocket")
var pluginUUID = flag.String("pluginUUID", "", "A unique identifier string that should be used to register the plugin once the WebSocket is opened")
var registerEvent = flag.String("registerEvent", "", "Registration event")
var info = flag.String("info", "", "A stringified json containing the Stream Deck application information and devices information")
func main() {
appdata := os.Getenv("APPDATA")
logpath := filepath.Join(appdata, "Elgato/StreamDeck/Plugins/com.exension.hwinfo.sdPlugin/hwinfo.log")
f, err := os.OpenFile(logpath, os.O_RDWR|os.O_CREATE, 0666)
f.Truncate(0)
if err != nil {
log.Fatalf("OpenFile Log: %v", err)
}
defer f.Close()
log.SetOutput(f)
log.SetFlags(0)
flag.Parse()
args := []string{
"-port",
*port,
"-pluginUUID",
*pluginUUID,
"-registerEvent",
*registerEvent,
"-info",
*info,
}
bytes, err := json.MarshalIndent(args, "", " ")
if err != nil {
log.Fatal("Failed to marshal args", err)
}
log.Println(string(bytes))
}

View File

@@ -0,0 +1,69 @@
package main
import (
"flag"
"io/ioutil"
"log"
// "net/http"
// _ "net/http/pprof"
"os"
"path/filepath"
plugin "github.com/shayne/hwinfo-streamdeck/internal/app/hwinfostreamdeckplugin"
)
var port = flag.String("port", "", "The port that should be used to create the WebSocket")
var pluginUUID = flag.String("pluginUUID", "", "A unique identifier string that should be used to register the plugin once the WebSocket is opened")
var registerEvent = flag.String("registerEvent", "", "Registration event")
var info = flag.String("info", "", "A stringified json containing the Stream Deck application information and devices information")
func main() {
// go func() {
// log.Println(http.ListenAndServe("localhost:6060", nil))
// }()
// make sure files are read relative to exe
err := os.Chdir(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatalf("Unable to chdir: %v", err)
}
// PRODUCTION
// LOGGING DISABLED:
//
log.SetOutput(ioutil.Discard)
// DEBUG LOGGING:
//
// appdata := os.Getenv("APPDATA")
// logpath := filepath.Join(appdata, "Elgato/StreamDeck/Plugins/com.exension.hwinfo.sdPlugin/hwinfo.log")
// f, err := os.OpenFile(logpath, os.O_RDWR|os.O_CREATE, 0666)
// if err != nil {
// log.Fatalf("OpenFile Log: %v", err)
// }
// err = f.Truncate(0)
// if err != nil {
// log.Fatalf("Truncate Log: %v", err)
// }
// defer func() {
// err := f.Close()
// if err != nil {
// log.Fatalf("File Close: %v", err)
// }
// }()
// log.SetOutput(f)
// log.SetFlags(0)
flag.Parse()
p, err := plugin.NewPlugin(*port, *pluginUUID, *registerEvent, *info)
if err != nil {
log.Fatal("NewPlugin failed:", err)
}
err = p.RunForever()
if err != nil {
log.Fatal("runForever", err)
}
}