Added support for remote0
This commit is contained in:
31
cmd/hwinfo-plugin/main.go
Normal file
31
cmd/hwinfo-plugin/main.go
Normal 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,
|
||||
})
|
||||
}
|
||||
46
cmd/hwinfo_debugger/main.go
Normal file
46
cmd/hwinfo_debugger/main.go
Normal 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))
|
||||
}
|
||||
69
cmd/hwinfo_streamdeck_plugin/main.go
Normal file
69
cmd/hwinfo_streamdeck_plugin/main.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user