plugin_init.go 913 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package LauncherPy
  2. import (
  3. "github.com/clockworkpi/LauncherGoDev/sysgo/UI"
  4. "github.com/cuu/gogame/time"
  5. "log"
  6. "os/exec"
  7. "os/user"
  8. )
  9. /******************************************************************************/
  10. type LauncherPyPlugin struct {
  11. UI.Plugin
  12. }
  13. func (self *LauncherPyPlugin) Init(main_screen *UI.MainScreen) {
  14. }
  15. func (self *LauncherPyPlugin) Run(main_screen *UI.MainScreen) {
  16. if main_screen != nil {
  17. main_screen.MsgBox.SetText("Rebooting to Launcher")
  18. main_screen.MsgBox.Draw()
  19. main_screen.SwapAndShow()
  20. time.BlockDelay(550)
  21. usr, _ := user.Current()
  22. dir := usr.HomeDir
  23. if usr.Username == "root" {
  24. dir = "/home/cpi"
  25. }
  26. cmd := exec.Command("sed", "-i", "s/launchergo/launcher/g", dir+"/.bashrc")
  27. err := cmd.Run()
  28. if err != nil {
  29. log.Println("sed failed", err)
  30. } else {
  31. cmd = exec.Command("sudo", "reboot")
  32. cmd.Run()
  33. }
  34. }
  35. }
  36. var APIOBJ LauncherPyPlugin