Hi,
can´t run these Geeklets on my computer. I´ve downloaded GeekTool from the MacAppStore, btw.
I did everything like you said, but if I write down the path in GeekTool or NerdTool, nothing happens. I think, I´m doing something wrong with this ruby-thing. The command is: "ruby /Users/Nils/Documents/Geektool/Process/cpumeter.rb"
I hope someone here can help me?
Nils
PS: Sorry for my english, I´m only 14 and german.
Try running that command in Terminal and see what you get. It's possible you need to specify a complete path to Ruby… i.e. /usr/bin/ruby
localhost:~ Nils$ /usr/bin/ruby /Users/Nils/Documents/Geektool/Process/cpumeter.rb
Top CPU processes
localhost:~ Nils$
That´s what I get when I run the file from Terminal. For me, it looks like it is running correctly. But GeekTool can´t run I anyways?
Thanks for your help!
Nils
Is GeekTool able to process other scripts for you? Do you have any others running on the Desktop that have a similar command?
load more (6 remarks)
Neat script, but your spacer function has a small off-by-one error, i.e. truncated output has a shorter column length.
Also, for some kind of reason, if I invoke ps
with -o "command %cpu"
, I get a truncated command line, which doesn't happen if I do a `-o "%cpu command".
So in my version I simply changed the regex, and then swapped $1 and $2 around in the body. Also, I used this spacer function, to make it easier if I ever wanted a wider version:
def spacer(str, max=16)
(str.length > max-1 ? "%-.#{max-2}s… " : "%-#{max}.#{max}s") % str
end
Thanks. That was kind of bugging me, but I did need metafour's fix to get the ellipses without the space. Using Brett's original script I was having spacing problems with the truncated lines so the alignment would get messed up.
That said, I'm really enjoying Brett's series on these additions. I had been just using GeekTool (now I'm using NerdTool) mainly to display keyboard shortcuts (and Dr. Drang's SuperDuper! log / Dropbox conflcts). Now, I'm trying to think of other things I might want on the desktop.
Your script seems to add a space between the end of the process name string and the ellipsis. I modified it so that the ellipsis is directly attached to the process name. Not sure if it's the best way to do it since I don't really know ruby.
(str.length > max-1 ? "%-.#{max - 3}s… " : "%-#{max}.#{max}s") % str