diff --git a/.gitignore b/.gitignore index e96b310..96a1fad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,15 @@ test main *.so +retroarch-core-options.cfg +*.lpl +*.swp +.bsv +*.pyc +sysgo/.powerlevel +sysgo/.buttonslayout +sysgo/.lang +*.cfg +**/Jobs/* +!**/Jobs/.gitkeep + diff --git a/main.go b/main.go index 7ac5c3e..404d73e 100644 --- a/main.go +++ b/main.go @@ -7,10 +7,11 @@ import ( "io/ioutil" "strconv" "strings" + "runtime" gotime "time" "github.com/veandco/go-sdl2/sdl" - + "github.com/cuu/gogame" "github.com/cuu/gogame/display" "github.com/cuu/gogame/event" // "github.com/cuu/gogame/color" @@ -199,6 +200,33 @@ func InspectionTeam(main_screen *UI.MainScreen) { } } +func PreparationInAdv(){ + + if strings.Contains(runtime.GOARCH,"arm") == false { + return + } + + if UI.FileExists("sysgo/.powerlevel") == false { + UI.System("touch sysgo/.powerlevel") + UI.System("sudo iw wlan0 set power_save off >/dev/null") + + }else{ + b, err := ioutil.ReadFile("sysgo/.powerlevel") + if err != nil { + log.Fatal(err) + } + + pwl := strings.Trim(string(b),"\r\n ") + + if pwl == "supersaving" { + UI.System("sudo iw wlan0 set power_save on >/dev/null") + }else{ + UI.System("sudo iw wlan0 set power_save off >/dev/null") + } + } + +} + func run() int { display.Init() font.Init() @@ -206,7 +234,9 @@ func run() int { UI.Init() UI.MyIconPool.Init() - + + PreparationInAdv() + main_screen := UI.NewMainScreen() main_screen.HWND = screen main_screen.Init() @@ -243,8 +273,25 @@ func run() int { break } if ev.Type == event.USEREVENT { - + + fmt.Println("UserEvent: ",ev.Data["Msg"]) + + switch ev.Code { + case UI.RUNEVT: + main_screen.OnExitCb() + gogame.Quit() + + fmt.Println("RUNEVT") + exec_app_cmd := "cd " + filepath.Dir(ev.Data["Msg"])+";" + exec_app_cmd += ev.Data["Msg"] + exec_app_cmd +="; sync & cd "+UI.GetExePath()+"; "+os.Args[0] + fmt.Println(exec_app_cmd) + + + } + + } if ev.Type == event.KEYDOWN { everytime_keydown = gotime.Now() diff --git a/sysgo/UI/util_funcs.go b/sysgo/UI/util_funcs.go index f6caa2c..d18ac04 100644 --- a/sysgo/UI/util_funcs.go +++ b/sysgo/UI/util_funcs.go @@ -111,6 +111,15 @@ func MakeExecutable(path string) { os.Chmod(path,mode) } +func GetExePath() string { + dir, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + return dir + +} + func ReplaceSuffix(orig_file_str string, new_ext string) string { orig_ext := filepath.Ext(orig_file_str) if orig_ext!= "" { @@ -226,3 +235,14 @@ func CheckBattery() int { return 0 } +func System(cmd string) string { + ret := "" + out,err := exec.Command("bash","-c",cmd).Output() + if err != nil { + fmt.Println(err) + }else { + ret = string(out) + } + + return ret +} diff --git a/sysgo/config.go b/sysgo/config.go index 78b692c..23fb206 100644 --- a/sysgo/config.go +++ b/sysgo/config.go @@ -22,7 +22,7 @@ var ( SKIN="default" //load from dot files - CurPowerLevel= "supersaving"//"performance" + CurPowerLevel= "performance" Lang = "English" )