Skip to content

Comments

Allow desc sorting and listing without filter#13

Open
yannickglt wants to merge 1 commit intongreenstein:masterfrom
yannickglt:feat/allow-sorting-and-no-filtering
Open

Allow desc sorting and listing without filter#13
yannickglt wants to merge 1 commit intongreenstein:masterfrom
yannickglt:feat/allow-sorting-and-no-filtering

Conversation

@yannickglt
Copy link

@yannickglt yannickglt commented Jun 16, 2017

  • The argument became optional in the workflow config permitting to display the top most consuming processes (thanks to awk 'NR>1') without having to type a piece of process name.
  • The awk 'NR>1' pipe remove the headers (PID %CPU COMM) and fix issue when displaying all elements or filtering on words containing "PID", "CPU", etc. (probably issue Stuck on "Finding processes..." #11)
  • The sort -nrk 2,2 pipe sorts results on the second column descending: CPU.
  • Remove the uid attribute is mandatory to get sorting working. If an UID is present on an element in the XML response, then Alfred will remember it and suggest it in the top ranked results if the user selected it in the past.

image

Closes #10, #11

@yannickglt
Copy link
Author

Hi @ngreenstein! Is it possible to merge this pull request?

@ngreenstein
Copy link
Owner

Hi @yannickglt, and thanks for this! Unfortunately, I don't have access to a copy of Alfred 3 to test this on (just 2), nor do I have a reliable Internet connection at the moment. I would love to merge this in the future, but, in the meantime, I encourage anyone who wishes to to download from this branch. Thanks again!

@yannickglt
Copy link
Author

It's OK! Thanks for your answer. I guess we can wait a bit more to get it merged 😉

@yannickglt
Copy link
Author

You can download Alfred Process Killer with sorting here

@codeversed
Copy link

I just updated it and it's working very well for me! Great work guys 👍

Copy link

@devnoname120 devnoname120 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, make sure to update the workflow binary after the changes.

end
# Assemble this item's XML string for Alfred. See http://www.alfredforum.com/topic/5-generating-feedback-in-workflows/
thisXmlString = "\t<item uid=\"#{processName}\" arg=\"#{processId}\">
thisXmlString = "\t<item arg=\"#{processId}\">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this configurable.

Also don't remove the uid but instead conditionally use skipknowledge to show the most killed processes before that the user starts typing a process name.

# The -A flag shows all processes. The -o pid, -o %cpu, and -o comm show only the process's PID, CPU usage and path, respectively.
# Grep for processes whose name contains the query. The regex isolates the name by only searching characters after the last slash in the path.
# The -i flag ignores case.
processes = `ps -A -o pid -o %cpu -o comm | grep -i [^/]*#{Regexp.quote(theQuery)}[^/]*$`.split("\n")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about using the dedicated GNU tool for that?

- awk 'NR>1'
+ sort -n +2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding support for sorting by process %cpu

4 participants