Display active network profile

This commit is contained in:
Brian Buller 2015-12-17 22:16:42 -06:00
parent 8c99923a50
commit 44b1a33efe

View File

@ -80,6 +80,8 @@ func (screen *mainScreen) drawScreen(style style) {
screen.battStat.GetX()+screen.battStat.GetWidth(), screen.battStat.GetX()+screen.battStat.GetWidth(),
screen.battStat.GetY(), style.defaultFg, style.defaultBg) screen.battStat.GetY(), style.defaultFg, style.defaultBg)
termboxUtil.DrawStringAtPoint(getNetworkProfile(), 0, h-1, style.defaultFg, style.defaultBg)
refreshText := "(r)efresh" refreshText := "(r)efresh"
if state.autoUpdate { if state.autoUpdate {
refreshText = "Auto-Refresh On (" refreshText = "Auto-Refresh On ("
@ -120,11 +122,20 @@ func getBatteryPct() int {
} }
func getNetworkProfile() string { func getNetworkProfile() string {
netProfile := "net_profile" netApp := "netctl"
cmd := exec.Command(netProfile) netArg1 := "list"
cmd := exec.Command(netApp, netArg1)
stdout, err := cmd.Output() stdout, err := cmd.Output()
if err != nil { if err == nil {
return "No Network" tst := string(stdout)
for _, k := range strings.Split(tst, "\n") {
pair := strings.Split(k, " ")
if len(pair) > 1 {
if pair[0] == "*" {
return pair[1]
} }
return string(stdout) }
}
}
return "No Network"
} }