Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Does not work correctly' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Does not work correctly
Authored by: ToMaToTaChi on Jul 08, '04 06:48:28PM
just needs a slight modification :)
 top -dl2 | grep sage | cut -c 33-88 | tail -1 
Oh, but that wasn't good enough nope nope. :)

top -dl2 | grep "sage" | cut -c 44-71 | tail -1 | awk '{ printf "CPU Time\nUsed: %04.2f%%\nIdle: %04.2f%%\n", (100 - $5), $5; }'
Well, I liked that fine, it could be a little more fun
So:

top -dl2 | grep "sage" | cut -c 44-71 | tail -1 | awk '{
  pe = 30;
  pa = "[]";
  pb = "--";

  z[0] = 100 - $5;
  z[1] = $5;
  z[2] = "Used";
  z[3] = "Idle";

  for( foo = 0; foo < 2; foo++ )
  {
    zzz = ( pe * z[foo] / 100) + 0;
    zzy = ( pe - zzz) + 0;
    zza = "\000";
    zzb = "\000";
    
    for( bar = 0; bar < zzz; bar++ )
      { zza = zza pa }
    for( bar = 0; bar < zzy; bar++ )
      { zzb = zzb pb }
    printf "%s %04.2f%% %s%s\n", z[foo+2], z[foo], zza, zzb; 
  }
}'

note, geektool does not appreciate line brakes; strip them prior to pasting. I posted like this for the sake of legibility -- it's down right painful to read all clumped on a single line.

-- one thing that bummed me out was geektool did not like my echo -e \033[##m coloration, inversion, etc. I had the thing looking pretty spiffy in terminal.app running bash. Bah. all yellow and red, it's pretty :D

Otherwise i'm having too much fun with this thing!



[ Reply to This | # ]
Exactly what I wanted
Authored by: GalainHH on Jul 09, '04 02:47:27AM

Thanks a lot,

your second code line does exactly what I wanted.

Thank you
GalainHH



[ Reply to This | # ]