mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2026-03-19 02:12:46 +01:00
replace wlan0 to sysgo.WifiDev
move execCmd to UI.ExecCmd add read app-local.ini in config.go for dev/ run launcher out of GameShell
This commit is contained in:
@@ -151,7 +151,7 @@ func (self *GateWayPage) GenList() {
|
||||
last_height := 0
|
||||
|
||||
var drivers = [][2]string{[2]string{"usb0","USB Ethernet"},
|
||||
[2]string{"wlan0","Wi-Fi"}}
|
||||
[2]string{sysgo.WifiDev,"Wi-Fi"}}
|
||||
|
||||
|
||||
for _,u := range drivers {
|
||||
@@ -318,8 +318,8 @@ func (self *GateWayPage) OnLoadCb() {
|
||||
if len(out) > 7 {
|
||||
if strings.Contains(out,"usb0") {
|
||||
thedrv = "usb0"
|
||||
}else if strings.Contains(out,"wlan0") {
|
||||
thedrv = "wlan0"
|
||||
}else if strings.Contains(out,sysgo.WifiDev) {
|
||||
thedrv = sysgo.WifiDev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,9 +502,9 @@ func (self *PowerOptionsPage) Click() {
|
||||
sysgo.CurPowerLevel = cur_li.Value
|
||||
|
||||
if sysgo.CurPowerLevel == "supersaving" {
|
||||
UI.System("sudo iw wlan0 set power_save on >/dev/null")
|
||||
UI.System(fmt.Sprintf("sudo iw %s set power_save on >/dev/null",sysgo.WifiDev))
|
||||
}else{
|
||||
UI.System("sudo iw wlan0 set power_save off >/dev/null")
|
||||
UI.System(fmt.Sprintf("sudo iw %s set power_save off >/dev/null",sysgo.WifiDev))
|
||||
}
|
||||
|
||||
self.Screen.MsgBox.SetText("Applying")
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Wifi"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Bluetooth"
|
||||
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/LauncherPy"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Update"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Storage"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Languages"
|
||||
@@ -29,7 +28,7 @@ import (
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Airplane"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/ButtonsLayout"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/TimeZone"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Lima"
|
||||
//"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/Lima"
|
||||
"github.com/clockworkpi/LauncherGoDev/Menu/GameShell/10_Settings/GateWay"
|
||||
|
||||
|
||||
@@ -117,8 +116,8 @@ func (self *SettingsPage) GenList() []*UI.UIPlugin {
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "About", "About", &About.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "PowerOFF", "Power off", &PowerOFF.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "ButtonsLayout", "Buttons Layout", &ButtonsLayout.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "LauncherPy", "Switch to Launcher", &LauncherPy.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "Lima", "GPU Driver Switch", &Lima.APIOBJ},
|
||||
// &UI.UIPlugin{UI.PluginPackage,"", "LauncherPy", "Switch to Launcher", &LauncherPy.APIOBJ},
|
||||
//&UI.UIPlugin{UI.PluginPackage,"", "Lima", "GPU Driver Switch", &Lima.APIOBJ},
|
||||
&UI.UIPlugin{UI.PluginPackage,"", "GateWay", "Network gateway switch", &GateWay.APIOBJ},
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func cmdEnv() []string {
|
||||
return []string{"LANG=C", "LC_ALL=C"}
|
||||
}
|
||||
|
||||
func getVolumeCmd() []string {
|
||||
if useAmixer {
|
||||
return []string{"amixer", "get", "Master"}
|
||||
|
||||
@@ -6,25 +6,16 @@ package Sound
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
//"fmt"
|
||||
//"os"
|
||||
//"os/exec"
|
||||
//"strings"
|
||||
"github.com/clockworkpi/LauncherGoDev/sysgo/UI"
|
||||
)
|
||||
|
||||
func execCmd(cmdArgs []string) ([]byte, error) {
|
||||
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
|
||||
cmd.Env = append(os.Environ(), cmdEnv()...)
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
err = fmt.Errorf(`failed to execute "%v" (%+v)`, strings.Join(cmdArgs, " "), err)
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
|
||||
// GetVolume returns the current volume (0 to 100).
|
||||
func GetVolume() (int, error) {
|
||||
out, err := execCmd(getVolumeCmd())
|
||||
out, err := UI.ExecCmd(getVolumeCmd())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -36,19 +27,19 @@ func SetVolume(volume int) error {
|
||||
if volume < 0 || 100 < volume {
|
||||
return errors.New("out of valid volume range")
|
||||
}
|
||||
_, err := execCmd(setVolumeCmd(volume))
|
||||
_, err := UI.ExecCmd(setVolumeCmd(volume))
|
||||
return err
|
||||
}
|
||||
|
||||
// IncreaseVolume increases (or decreases) the audio volume by the specified value.
|
||||
func IncreaseVolume(diff int) error {
|
||||
_, err := execCmd(increaseVolumeCmd(diff))
|
||||
_, err := UI.ExecCmd(increaseVolumeCmd(diff))
|
||||
return err
|
||||
}
|
||||
|
||||
// GetMuted returns the current muted status.
|
||||
func GetMuted() (bool, error) {
|
||||
out, err := execCmd(getMutedCmd())
|
||||
out, err := UI.ExecCmd(getMutedCmd())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -57,12 +48,12 @@ func GetMuted() (bool, error) {
|
||||
|
||||
// Mute mutes the audio.
|
||||
func Mute() error {
|
||||
_, err := execCmd(muteCmd())
|
||||
_, err := UI.ExecCmd(muteCmd())
|
||||
return err
|
||||
}
|
||||
|
||||
// Unmute unmutes the audio.
|
||||
func Unmute() error {
|
||||
_, err := execCmd(unmuteCmd())
|
||||
_, err := UI.ExecCmd(unmuteCmd())
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ var (
|
||||
|
||||
|
||||
func (self *WifiPlugin) Init( main_screen *UI.MainScreen ) {
|
||||
|
||||
|
||||
self.PasswordPage = UI.NewKeyboard()
|
||||
self.PasswordPage.Name = "Enter wifi password"
|
||||
self.PasswordPage.Screen= main_screen
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"fmt"
|
||||
//"strconv"
|
||||
"strings"
|
||||
"os"
|
||||
"os/exec"
|
||||
//"os"
|
||||
// "os/exec"
|
||||
gotime "time"
|
||||
|
||||
//"github.com/godbus/dbus"
|
||||
@@ -33,21 +33,6 @@ type WifiDisconnectConfirmPage struct {
|
||||
Parent *WifiInfoPage
|
||||
}
|
||||
|
||||
func cmdEnv() []string {
|
||||
return []string{"LANG=C", "LC_ALL=C"}
|
||||
}
|
||||
|
||||
func execCmd(cmdArgs []string) ([]byte, error) {
|
||||
cmd := exec.Command(cmdArgs[0], cmdArgs[1:]...)
|
||||
cmd.Env = append(os.Environ(), cmdEnv()...)
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
err = fmt.Errorf(`failed to execute "%v" (%+v)`, strings.Join(cmdArgs, " "), err)
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
|
||||
|
||||
func NewWifiDisconnectConfirmPage() *WifiDisconnectConfirmPage {
|
||||
p := &WifiDisconnectConfirmPage{}
|
||||
p.ListFont = UI.Fonts["veramono20"]
|
||||
@@ -488,10 +473,10 @@ func (self *WifiList) Disconnect() {
|
||||
self.Connecting = false
|
||||
|
||||
wpa_cli_disconnect := []string{"wpa_cli","disconnect",self.CurEssid,"-i",sysgo.WifiDev}
|
||||
execCmd( wpa_cli_disconnect )
|
||||
UI.ExecCmd( wpa_cli_disconnect )
|
||||
fmt.Println(wpa_cli_disconnect)
|
||||
dhcp_release := []string{"dhclient","-r",sysgo.WifiDev}
|
||||
execCmd(dhcp_release)
|
||||
UI.ExecCmd(dhcp_release)
|
||||
|
||||
self.CurEssid = ""
|
||||
self.CurBssid = ""
|
||||
@@ -578,7 +563,7 @@ func (self *WifiList) ConfigWireless(password string) {
|
||||
self.CurBssid = self.MyList[self.PsIndex].Bssid
|
||||
self.MyList[self.PsIndex].Password = password
|
||||
dhcp := []string{"dhclient" ,sysgo.WifiDev}
|
||||
execCmd(dhcp)
|
||||
UI.ExecCmd(dhcp)
|
||||
GsConnectManager.ReadNetAddress(gotime.Second*3)
|
||||
self.CurIP = GsConnectManager.IPv4().String()
|
||||
self.ShowBox("Connected")
|
||||
@@ -603,10 +588,8 @@ func (self *WifiList) ConfigWireless(password string) {
|
||||
func (self *WifiList) GetWirelessIP() string {
|
||||
|
||||
cli := fmt.Sprintf( "ip -4 addr show %s | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}'",sysgo.WifiDev)
|
||||
out := UI.System(cli)
|
||||
if len(out) > 5 {
|
||||
out = strings.TrimSuffix(out,"\n")
|
||||
}
|
||||
out := UI.SystemTrim(cli)
|
||||
|
||||
return out
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user