From 0450de636f5a875b3b5b2234fde7e461744f0b77 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 28 Apr 2023 07:26:55 -0500 Subject: [PATCH] use the compiled in plugins Signed-off-by: Jeff Carr --- Makefile | 5 ++++- apt.go | 4 +++- gui.go | 5 +++++ main.go | 11 +++++++++-- os.go | 21 --------------------- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index c0d8146..41159e5 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,10 @@ build: # reset -cp ~/go/src/git.wit.org/wit/gui/toolkit/*.so resources/toolkits/ GO111MODULE="off" go build -v - ./wit-new-machine + ./wit-new-machine --gui-toolkit gocui >/tmp/witgui.log.stderr 2>&1 + +nocui: + ./wit-new-machine --gui-toolkit nocui release: wit go update diff --git a/apt.go b/apt.go index 3749c8e..1f7ecf2 100644 --- a/apt.go +++ b/apt.go @@ -17,6 +17,7 @@ func aptTab() { writeRes("resources/", "/etc/", "apt/sources.list") writeRes("resources/", "/etc/", "apt/sources.list.d/wit.list") writeRes("resources/", "/etc/", "apt/sources.list.d/debian.list") + doCmd("mkdir /etc/wit/") writeRes("resources/apt/", "/etc/wit/", "wit.gpg") doCmd("apt update") doCmd("apt dist-upgrade") @@ -29,7 +30,8 @@ func aptTab() { myGui.CloseToolkit("gocui") doCmd("apt install apt-file") doCmd("apt-file update") - doCmd("apt-file -x search '/libOpenCL.so.1'") + doCmd("apt-file -x search /libOpenCL.so.1") + // doCmd("apt-file -x search '/libOpenCL.so.1'") os.Exit(0) }) diff --git a/gui.go b/gui.go index 153e596..84e77eb 100644 --- a/gui.go +++ b/gui.go @@ -1,6 +1,7 @@ package main import ( "log" + "fmt" "time" "os" "io/ioutil" @@ -65,6 +66,10 @@ func drawWindow() { gui.DebugWindow() }) + g.NewButton("hello", func () { + fmt.Println("world") + }) + ///////////////////////////////////////////////////////////////////////////// rn := newTab.NewGroup("Local Linux Settings") diff --git a/main.go b/main.go index bace5ad..fd0f032 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,9 @@ var geom string = "120x30+500+500" //go:embed resources var res embed.FS +//go:embed resources/toolkits +var resToolkit embed.FS + //go:embed resources/ttyS0.conf var ttyS0 string @@ -50,8 +53,12 @@ func main() { os.Exit(0) } - // myGui = gui.New().LoadToolkit("gocui") - myGui = gui.New().Default() + if (args.GuiToolkit == nil) { + myGui = gui.New().InitEmbed(resToolkit).Default() + } else { + myGui = gui.New().InitEmbed(resToolkit).LoadToolkit(args.GuiToolkit[0]) + } + drawWindow() gui.Watchdog() diff --git a/os.go b/os.go index 1578f99..d0daa88 100644 --- a/os.go +++ b/os.go @@ -100,24 +100,3 @@ func runLinuxCommand(cmdArgs []string) (string, error) { log.Println(string(bytes)) return string(bytes), err } - -/* -TODO: rewrite this using go:embed -func packrSaveFile(packrname string, filename string) error { - log.Println("packrSaveFile() for", packrname) - b, _ := packrBox.FindString(packrname) - log.Println(packrname, "=\n\n", b) - spew.Dump(b) - - f, err := os.Create(filename) - if err != nil { - return err - } - defer f.Close() - w := bufio.NewWriter(f) - n4, err := w.WriteString(b) - log.Println("n4 =", n4) - w.Flush() - return nil -} -*/