Giter Site home page Giter Site logo

zhaocai / alfred2-top-workflow Goto Github PK

View Code? Open in Web Editor NEW
520.0 24.0 37.0 11.82 MB

Alfred 2 Workflow: 1) Top Processes Based Memory, CPU, and IO Usage; 2) Get a Glance of System Status

Home Page: http://zhaocai.github.com/alfred2-top-workflow/

Ruby 88.91% D 10.12% Shell 0.97%

alfred2-top-workflow's Introduction

Alfred 2 Top Process Workflow

The initial motive of this workflow is to avoid frequent visits to the Activity Monitor when the fan goes loud. Now it has been evolved with two major features:

    1. List/Kill Top Processes by Memory/CPU/IO Usage

    1. (working in progress) Get a glance of system status including internal battery, fan speed, CPU/GPU Temperature, bluetooth battery, disk capacity, etc.

Usage

0. Show Help

Just type -?, -h, or --help after the keyword to show help.

1. Top Processes

A. Keywords:

1.) top: Show a mixed processes list based on top cpu/memory usage.
1. top -m, top --memory to show processes ranked by memory usage
2. top -c, top --cpu, to show processes ranked by cpu usage
3. top -i, top --io, to show processes ranked by io usage with callback from top io trace collector.

Top IO requires DTrace and it would take a while to finish. The new callback design is to run the job in he background and post a notification (OSX 10.8+) using notification center. Click on the notification to show the result in alfred.

Modifier Key
  • none : The default action is to list files opened by process ID
  • control : Kill the selected process
  • command : kill forcefully (kill -9)
  • alt : Nice (lower) the selected process's cpu priority
  • shift : Search web for process information
2.) kill: Filter process to kill.
Modifier Key
  • none: The default action is to kill by process ID
  • command : kill forcefully (kill -9)
3.) lsof: List files opened by process id
Modifier Key
  • none: The default action is to reveal file in Finder

B. Filter by Query

1.) Type process name to filter

2.) To search for process state, use :idle, :sleep, :stopped, :zombie, :uninterruptible, :runnable, etc.

2. Glance an Eye on your system

A. Keywords:

  1. glance: Show system information including internal battery, bluetooth battery, disk capacity, etc.

B. Change Display Order

  1. Activate Alfred Preferences โ†’ Advanced โ†’ Top Result Keyword Latching

  2. Hit Enter for the feedback item you wish to show up on the top.

Installation

Two ways are provided:

  1. You can download the Top Processes.alfredworkflow and import to Alfred 2. This method is suitable for regular users.

  2. You can git clone or fork this repository and use rake install and rake uninstall to install. Check rake -T for available tasks. This method create a symlink to the alfred workflow directory: "~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows". This method is suitable for developers.

Troubleshooting

1. Does not work in Mac OSX 10.9 (Maverick)

In OSX 10.9, the system ruby is upgraded to 2.0.0. You need to download the new version of this workflow which packs the ruby gems for 2.0.0 inside.

If the downloaded version does not work, try

1.) open Terminal.app. If you use rvm or rbenv, switch to the system ruby. 2. run cd "$HOME/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/me.zhaowu.top" && rake bundle:update

2. iotop causes mouse lagging

This issue is not caused by this workflow but by DTrace. The related system log message is IOHIDSystem cursor update overdue. Resending.. In my Macbook Pro, any DTrace based program will introduce this issue including the mac built-in /usr/bin/iotop, and /Applications/Xcode.app/Contents/Applications/Instruments.app .

I upgrade to OS X 10.9 and this issue is resolved.

3. Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8

Add the following contents to /etc/launchd.conf. Restart is required.

setenv LANG en_US.UTF-8
setenv LC_ALL en_US.UTF-8

Copyright

Copyright (c) 2013 Zhao Cai [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

alfred2-top-workflow's People

Contributors

jeffnuss avatar zhaocai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alfred2-top-workflow's Issues

top -c as default?

Hey,
is it possible to make "top" -c the default sort method when i just type "top"?
Let's take the initiative and set one order default; would prefer that over randomly sorted items until i decide to be specific.

Thx,
Louis

top not working in beta of a certain new desktop OS

I'm using the latest non-big-cats named version of OS X. This WONDERFUL Alfred Workflow is not working in this new version of my desktop OS. I type "top" and the only thing that appears is the "Help! Show me the usage page!" link. The wonderful display of top does not appear. Nor does it work with the keyboard shortcut.

** For the record, it worked fine in 10.8.x for me. I loved it! I'm only reporting this so it's on record (and in case someone else reports contradictory success - as I'd love to be able to fix it on my end **

(Please forgive me for sounding vague or confusing -- I'm trying to avoid saying the word or using the numbers. Once upon a time someone was upset with me for mentioning a beta version in an issue queue -- because of NDA's and what-not).

Cheers

cannot run on MAC 10.13.6

in Alfred after tapping top get

Starting debug for 'Top Processes'

[2019-03-24 21:11:41][ERROR: input.scriptfilter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- alfred (LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from ./alfred2_top_workflow.rb:20:in `<main>'

Top /io

Gather processes consuming most io.

options

  1. iotop is too slow and could hang the mouse cursor.
  2. fs_usage

There's some problem that I don't quite understand

ERROR: Top Processes[Script Filter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:inrequire': cannot load such file -- alfred (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' from ./alfred2_top_workflow.rb:20:in

'`
Thank you so much for such a good workflow
And I would appreciate that if you tell how to fix that.

Error when running any of the commands

ERROR  me.zhaowu.top : A fatal error has occurred. You may seek help in the Alfred supporting site, forum or raise an issue in the bug tracking site.
  #<NoMethodError: undefined method `ljust' for nil:NilClass>
  ./alfred2_top_workflow.rb:235:in `generate_feedback'  
./alfred2_top_workflow.rb:219:in `each'  
./alfred2_top_workflow.rb:219:in `generate_feedback'  
./alfred2_top_workflow.rb:259  
/Users/trodrigues/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.B69DA4EF-206C-4D10-A891-33BA2B8D29C6/bundle/ruby/1.8/gems/alfred-workflow-1.2.7/lib/alfred.rb:26:in `with_friendly_error'  
./alfred2_top_workflow.rb:253

Can't show process id

If I want to use cmd "lsof",I should query the process id by appName,but there is no function to query the process id?

glance/lsof crash on null dereference.

Tried installing through repo and standard point and click, both resulted in the following error:

$ tail /Users/pedram/Library/Logs/Alfred-Workflow.log

E, [2013-11-12 00:55:42 #10433] ERROR -- me.zhaowu.top: A fatal error has occurred. You may seek help in the Alfred supporting site, forum or raise an issue in the bug tracking site.
  #<NoMethodError: undefined method `split' for nil:NilClass>
  ./glance.rb:46:in `collect_temperature'
./glance.rb:32:in `collect'
./glance.rb:284:in `generate_feedback'
./glance.rb:293:in `block in <main>'
/Users/pedram/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.316E8A5F-6CC4-42E1-93C2-5D379CEECA78/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred.rb:82:in `with_friendly_error'
./glance.rb:291:in `<main>'

Cannot kill system processes, no sudo support

Sometimes I want to kill coreaudiod (sound stack) or blued (bluetooth stack) because they do not work anymore.
But kill in alfred do no do sudo elevation. Could it be added? Can't kill those without sudo

broken on alfred 3.0

ERROR me.zhaowu.top : A fatal error has occurred. You may seek help in the Alfred supporting site, forum or raise an issue in the bug tracking site.
#<ArgumentError: invalid byte sequence in UTF-8>
./alfred2_top_workflow.rb:131:in split' ./alfred2_top_workflow.rb:131:inblock in ps_list'
./alfred2_top_workflow.rb:130:in each' ./alfred2_top_workflow.rb:130:inps_list'
./alfred2_top_workflow.rb:168:in top_processes' ./alfred2_top_workflow.rb:257:inblock in

'
.../Alfred.alfredpreferences/workflows/user.workflow.C6BEF5BB-68AE-4C94-965E-D9D1686C3344/bundle/ruby/2.0.0/gems/alfred-workflow-1.2.7/lib/alfred.rb:26:in with_friendly_error' ./alfred2_top_workflow.rb:246:in'

Glance doesn't work on my MacBook (12 inch)

The error message is :

E, [2015-09-05 10:14:40 #23264] ERROR -- me.zhaowu.top: A fatal error has occurred. You may seek help in the Alfred supporting site, forum or raise an issue in the bug tracking site.
#<NoMethodError: undefined method <' for nil:NilClass> ./glance.rb:88:in add_fan_speed_item'
./glance.rb:74:incollect_temperature' ./glance.rb:48:in collect'
./glance.rb:315:ingenerate_feedback' ./glance.rb:324:in block in

'
/Users/haochen/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.67043319-BB4F-4FC1-B51F-399C52649E40/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred.rb:82:inwith_friendly_error' ./glance.rb:322:in '

I guess it's because that the new MacBook doesn't have a fan, so you don't get the fan speed.

rake install doesnt work

Hello

I just cloned the repo today and when I run rake install or rake -T, inside the repo, I get the following error:

alfred2-top-workflow/ (master) $ rake -T
rake aborted!
cannot load such file -- plist
/User/x/alfred_workflows/alfred2-top-workflow/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

Activity Monitor Memory Consumption

Hello,

This is more a feature request:

In Activity Monitor, it shows the total memory that is used, the memory that is wired etc.

Is it possible to get that value as well in this workflow.

Doesn't work on OSX 10.11

Hey,
Looks really cool, but it doesn't work on my machine.
Also tried to run the 10.9 fix and got an error. Is this a known issue?

Thanks

Mavericks issue

Hi there! As lovin' this workflow I got sad after upgrading my Mac to 10.9. Now it seems to be broken as there are no processes showing up in the list.

top -i throws fatal error

Each time I run top -i I get a silent, but logged fatal error - see below:

E, [2017-08-04 10:33:32 #16288] ERROR -- me.zhaowu.top: A fatal error has occurred. You may seek help in the Alfred supporting site, forum or raise an issue in the bug tracking site.
  #<NoMethodError: undefined method `each_pair' for []:Array>
  ./alfred2_top_workflow.rb:131:in `generate_feedback'  
./alfred2_top_workflow.rb:204:in `on_action'  
/Users/tim/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.039791F6-83CA-41DF-A832-105259E169BF/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred.rb:229:in `block in start_handler'  
/Users/tim/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.039791F6-83CA-41DF-A832-105259E169BF/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred/handler.rb:126:in `block in each_handler'  
(eval):53:in `each'  
(eval):53:in `each'  
/Users/tim/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.039791F6-83CA-41DF-A832-105259E169BF/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred/handler.rb:125:in `each_handler'  
/Users/tim/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.039791F6-83CA-41DF-A832-105259E169BF/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred.rb:228:in `start_handler'  
/Users/tim/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.039791F6-83CA-41DF-A832-105259E169BF/bundle/ruby/2.0.0/gems/alfred-workflow-2.0.5/lib/alfred.rb:83:in `with_friendly_error'  
./alfred2_top_workflow.rb:424:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.