diff options
author | Caleb Bassi <calebjbassi@gmail.com> | 2018-05-23 16:53:04 -0700 |
---|---|---|
committer | Caleb Bassi <calebjbassi@gmail.com> | 2018-05-23 17:08:33 -0700 |
commit | ae2fff96558f0336cd8978fb8456a7453c52a008 (patch) | |
tree | 1b455d7cb49dd1069f0617a41ae345f88f5ce534 | |
parent | 6e1f7293e096fbaca6bd8d413a1f48769d67b882 (diff) |
Make ps command work on OSX
-rw-r--r-- | src/widgets/proc_unix.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/widgets/proc_unix.go b/src/widgets/proc_unix.go index 2253aca..b422737 100644 --- a/src/widgets/proc_unix.go +++ b/src/widgets/proc_unix.go @@ -22,10 +22,11 @@ func (self *Proc) update() { } func Processes() []Process { - output, _ := exec.Command("ps", "--no-headers", "-axo", "pid,comm,pcpu,pmem,args").Output() - strOutput := strings.TrimSpace(string(output)) + output, _ := exec.Command("ps", "-axo", "pid,comm,pcpu,pmem,args").Output() + // converts to []string and removes the header + strOutput := strings.Split(strings.TrimSpace(string(output)), "\n")[1:] processes := []Process{} - for _, line := range strings.Split(strOutput, "\n") { + for _, line := range strOutput { split := strings.Fields(line) pid, _ := strconv.Atoi(split[0]) cpu, _ := strconv.ParseFloat(split[2], 64) |