summaryrefslogtreecommitdiffstats
path: root/widgets/proc.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/proc.go')
-rw-r--r--widgets/proc.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/widgets/proc.go b/widgets/proc.go
index 408906c..d332a15 100644
--- a/widgets/proc.go
+++ b/widgets/proc.go
@@ -25,6 +25,7 @@ const (
ProcSortCPU ProcSortMethod = "c"
ProcSortMem = "m"
ProcSortPid = "p"
+ ProcSortCmd = "n"
)
type Proc struct {
@@ -188,6 +189,9 @@ func (proc *ProcWidget) sortProcs() {
case ProcSortMem:
sort.Sort(sort.Reverse(SortProcsByMem(*procs)))
proc.Header[3] += _downArrow
+ case ProcSortCmd:
+ sort.Sort(sort.Reverse(SortProcsByCmd(*procs)))
+ proc.Header[1] += _downArrow
}
}
@@ -336,3 +340,20 @@ func (procs SortProcsByMem) Swap(i, j int) {
func (procs SortProcsByMem) Less(i, j int) bool {
return procs[i].Mem < procs[j].Mem
}
+
+type SortProcsByCmd []Proc
+
+// Len implements Sort interface
+func (procs SortProcsByCmd) Len() int {
+ return len(procs)
+}
+
+// Swap implements Sort interface
+func (procs SortProcsByCmd) Swap(i, j int) {
+ procs[i], procs[j] = procs[j], procs[i]
+}
+
+// Less implements Sort interface
+func (procs SortProcsByCmd) Less(i, j int) bool {
+ return strings.ToLower(procs[j].CommandName) < strings.ToLower(procs[i].CommandName)
+}