wit-new-machine/gui.go

113 lines
2.8 KiB
Go
Raw Normal View History

2023-04-12 12:21:23 -05:00
package main
2023-04-12 12:21:23 -05:00
import (
"io/ioutil"
"os"
"time"
"go.wit.com/lib/debugger"
"go.wit.com/gui"
"go.wit.com/log"
2023-04-12 12:21:23 -05:00
)
var myGui *gui.Node
var mainWindow *gui.Node
func customExit() {
log.Println("Should Exit Here")
// window := gui.Data.WindowMap["Debugging2"]
// spew.Dump(window)
time.Sleep(2 * time.Second)
log.Println("")
log.Println("CLEAN EXIT")
log.Println("")
os.Exit(0)
}
var xtermHold *gui.Node
var padding *gui.Node
var firefox *gui.Node
var resolv *gui.Node
func writeRes(indir string, outdir string, name string) {
tmp, _ := res.ReadFile(indir + name)
ioutil.WriteFile(outdir+name, tmp, 0644)
}
// myGui = gui.New().LoadToolkit("gocui")
func drawWindow() {
2023-04-12 12:21:23 -05:00
var g *gui.Node
mainWindow = myGui.NewWindow("wit new machine setup").SetText("wit new machine setup")
mainWindow.Custom = customExit
newTab := mainWindow.NewTab("mainTab")
2023-04-12 12:21:23 -05:00
//////////////////// General GUI debugging /////////////////////////
g = newTab.NewGroup("Debug")
// g = mainWindow.NewGroup("Debug")
2023-04-12 12:21:23 -05:00
padding = g.NewCheckbox("padding")
xtermHold = g.NewCheckbox("xterm -hold")
firefox = g.NewCheckbox("Use Firefox")
g.NewLabel("resolv.conf")
resolv = g.NewTextbox("resolv")
resolv.Dump()
2023-04-12 12:21:23 -05:00
resolv.SetText("hello world\nfoo bar\n")
/////////////////////////////////////////////////////////////////////////////
rn := newTab.NewGroup("Local Linux Settings")
rn.NewButton("purge rc-only", func() {
2023-04-12 12:21:23 -05:00
xterm("cd ~/jcarr/setup; make reset-purge-rc-only-packages")
})
rn.NewButton("install kvm", func() {
2023-04-12 12:21:23 -05:00
xterm("cd ~/jcarr/setup; make setup-packages-kvm")
})
rn.NewButton("ttyS0", func() {
myGui.CloseToolkit("gocui")
// systemctl enable serial-getty@ttyS0.service
// cp ttyS0.conf /etc/init/
if _, err := os.Stat("/etc/init.d/ttyS0"); err == nil {
log.Println("serial ttyS0 is already configured")
} else {
foo := []byte(ttyS0)
ioutil.WriteFile("/etc/init.d/ttyS0", foo, 0644)
doCmd("ls -l")
doCmd("cat /etc/init.d/ttyS0")
doCmd("systemctl enable serial-getty@ttyS0.service")
doCmd("service serial-getty@ttyS0 start")
// /etc/securetty
}
if _, err := os.Stat("/etc/default/grub.d/wit.cfg"); err == nil {
log.Println("Grub is already configured")
} else {
writeRes("resources/", "/etc/default/", "grub.d/wit.cfg")
// grub, _ := res.ReadFile("resources/grub.d/wit.cfg")
// ioutil.WriteFile("/etc/default/grub.d/wit.cfg", grub, 0644)
doCmd("update-grub")
}
os.Exit(0)
})
rn.NewButton("git config", func() {
myGui.CloseToolkit("gocui")
doCmd("git config pull.rebase false")
os.Exit(0)
})
rn.NewButton("DebugWindow()", func() {
debugger.DebugWindow(myGui)
})
2023-04-12 12:21:23 -05:00
rn.NewLabel("Not yet working stuff")
rn.NewButton("resolv.conf", func() {
2023-04-12 12:21:23 -05:00
s := resolv.GetText()
log.Println("supposed to make the resolv.conf window\n\n", s)
})
aptTab()
2023-04-12 12:21:23 -05:00
}