anirudhajith / process-wallpaper

Shell and python scripts for setting your desktop wallpaper to a ~live word cloud of your most resource-hungry processes
GNU General Public License v3.0
544 stars 52 forks source link

Use psutil instead of top output. #20

Open dsluo opened 5 years ago

dsluo commented 5 years ago

This will ensure better compatibility as psutil takes care of all that for us and a better API as top wasn't really meant to be machine readable anyway.

anirudhajith commented 5 years ago

@dsluo I compared the output of psutil on macOS and on Ubuntu Linux a couple of days ago. Sadly, they're not consistent either...

dsluo commented 5 years ago

@anirudhajith What do you mean? Can you provide an example?

anirudhajith commented 5 years ago

@dsluo I stand corrected. I checked psutil's output on my friend's MacBook. It's consistent for the most part. WE ARE GO FOR PSUTIL!

anirudhajith commented 5 years ago

@dsluo I've attempted a port to psutil on a new branch: d7531658f1e07c00819d24998d1aec54c3498716 This should work on all platforms since we're not relying on the precise format of the output of top.

dsluo commented 5 years ago

@anirudhajith alright, I'm gonna pull the branch and make some changes.

dsluo commented 5 years ago

@anirudhajith according to psutil's docs, the first time that cpu_percent is retrieved, it will always return 0% CPU usage. As such all processes from when you iterate through psutil.process_iter will have 0% CPU.

dsluo commented 5 years ago

@anirudhajith I've pushed some changes to the psutil branch that should address this.