feat: was added option to disable the top processes (0 - option in the number of processes)

This commit is contained in:
Serhiy Mytrovtsiy
2021-01-07 16:29:03 +01:00
parent 75b75379e2
commit cc1d9459e1
8 changed files with 24 additions and 4 deletions

View File

@@ -57,7 +57,8 @@ internal class Popup: NSView, Popup_p {
}
private var processesHeight: CGFloat {
get {
return (self.processHeight*CGFloat(self.numberOfProcesses))+Constants.Popup.separatorHeight
let num = self.numberOfProcesses
return (self.processHeight*CGFloat(num)) + (num == 0 ? 0 : Constants.Popup.separatorHeight)
}
}
private var timeFormat: String {

View File

@@ -229,6 +229,10 @@ public class ProcessReader: Reader<[TopProcess]> {
}
public override func read() {
if self.numberOfProcesses == 0 {
return
}
let task = Process()
task.launchPath = "/usr/bin/top"
task.arguments = ["-l", "1", "-o", "power", "-n", "\(self.numberOfProcesses)", "-stats", "pid,command,power"]

View File

@@ -51,7 +51,8 @@ internal class Popup: NSView, Popup_p {
}
private var processesHeight: CGFloat {
get {
return (self.processHeight*CGFloat(self.numberOfProcesses))+Constants.Popup.separatorHeight
let num = self.numberOfProcesses
return (self.processHeight*CGFloat(num)) + (num == 0 ? 0 : Constants.Popup.separatorHeight)
}
}

View File

@@ -174,6 +174,10 @@ public class ProcessReader: Reader<[TopProcess]> {
}
public override func read() {
if self.numberOfProcesses == 0 {
return
}
let task = Process()
task.launchPath = "/bin/ps"
task.arguments = ["-Aceo pid,pcpu,comm", "-r"]

View File

@@ -64,7 +64,8 @@ internal class Popup: NSView, Popup_p {
}
private var processesHeight: CGFloat {
get {
return (self.processHeight*CGFloat(self.numberOfProcesses))+Constants.Popup.separatorHeight
let num = self.numberOfProcesses
return (self.processHeight*CGFloat(num)) + (num == 0 ? 0 : Constants.Popup.separatorHeight)
}
}

View File

@@ -274,6 +274,10 @@ public class ProcessReader: Reader<[Network_Process]> {
}
public override func read() {
if self.numberOfProcesses == 0 {
return
}
let task = Process()
task.launchPath = "/usr/bin/nettop"
task.arguments = ["-P", "-L", "1", "-k", "time,interface,state,rx_dupe,rx_ooo,re-tx,rtt_avg,rcvsize,tx_win,tc_class,tc_mgt,cc_algo,P,C,R,W,arch"]

View File

@@ -48,7 +48,8 @@ internal class Popup: NSView, Popup_p {
}
private var processesHeight: CGFloat {
get {
return (self.processHeight*CGFloat(self.numberOfProcesses))+Constants.Popup.separatorHeight
let num = self.numberOfProcesses
return (self.processHeight*CGFloat(num)) + (num == 0 ? 0 : Constants.Popup.separatorHeight)
}
}

View File

@@ -116,6 +116,10 @@ public class ProcessReader: Reader<[TopProcess]> {
}
public override func read() {
if self.numberOfProcesses == 0 {
return
}
let task = Process()
task.launchPath = "/usr/bin/top"
task.arguments = ["-l", "1", "-o", "mem", "-n", "\(self.numberOfProcesses)", "-stats", "pid,command,mem"]