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


Click here to return to the 'rest of the script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
rest of the script
Authored by: porkchop_d_clown on Feb 06, '02 11:51:39AM

The comment form truncated the script. Here's the last part:

-- Returns a list of the largest num applications on get_big_procs(num) do shell script "ps auxmww" set r to paragraphs 2 through (num + 2) of result as list set o to "" repeat with c from 1 to num set e to item c of r -- get size rounded to nearest MB set vsz to ((word 6 of e) as integer) + 512 set vsz to ((vsz - (vsz mod 1024)) / 1024) as integer set o to o & return & " " & vsz & " MB " -- extract the process name set AppleScript's text item delimiters to {""} set ao to offset of "/" in e set a to (text items ao through -1 of e) as string -- if the name contains ".app", truncate the name there. set ao to offset of ".app" in a if (ao is not 0) then set a to (text items 1 through (ao - 1)) of a as string -- extract the executable name from the process name. set AppleScript's text item delimiters to {"/"} set a to text item -1 of a set o to o & a end repeat return o end get_big_procs


[ Reply to This | # ]
Max No of App Details?
Authored by: wuf810 on Feb 06, '02 07:12:23PM

Is there anyway to increase the number of Top "n" apps? Even though I modified the variable used for the loop, it appears (for me at least) that the maximum is 7. Any ideas?



[ Reply to This | # ]
Max No of App Details?
Authored by: porkchop_d_clown on Feb 06, '02 10:44:42PM

I think the problem is that there is some upper limit to the # of characters you can send to a dialog. Try this: replace the top portion of the script (everything above 'on vmparse(x,n)') with this code:


-- Change this to change the # of applications displayed.
set MaxProcs to 10

if (MaxProcs is less than or equal to 5) then
set dstring to "OS X Virtual Memory Statistics:" & return
set dstring to dstring & get_swap_info()
set dstring to dstring & return & return & "Top " & MaxProcs & " Applications: "
set dstring to dstring & get_big_procs(MaxProcs)
display dialog dstring buttons {"Ok"} default button 1
else
display dialog "OS X Virtual Memory Statistics:" & return & get_swap_info() buttons {"More Info", "Done"} default button 1

if (button returned of the result is "More Info") then
display dialog "Top " & MaxProcs & " Applications: " & get_big_procs(MaxProcs) buttons {"Done"} default button 1
end if
end if

This fragment will display one dialog if you ask for 5 or fewer apps, and two dialogs if you want more than 5. I'm also working on a version that handles UNIX command line arguments correctly.



[ Reply to This | # ]
Max No of App Details?
Authored by: petey on Feb 07, '02 02:55:34AM

rather than fragment into 2 dialogs, get rid of the text section headers. that gives room for a few more apps. using my layout, i can fit 9 - 11 depending on length of the app names.

and Porkchop,

i like your code much better than mine, but i like my display layout much better than yours. keep it sparse and easy to read at a glance. and keep apps under 10MB left aligned.

now that you've learned AS, will you please learn AS Studio? all i want for Christmas is to have this info always sitting in a window on the desktop. i'm limping along with 384MB, which really isn't enough for this OS, so i need to do manual memory management. actually, all i want for Christmas is for 512MB laptop RAM modules to get cheap.



[ Reply to This | # ]
Max No of App Details?
Authored by: porkchop_d_clown on Feb 08, '02 10:53:35AM

heh. No sympathy from me - I'm using a 256mb iBook.

Believe it or not, I was downloading the developer tools when I read your message last night. Stayed up till 3 playing with it. (No, I have no life whatsoever. :-P) I've got something that's so-so about doing what you want. I couldn't get it to refresh at a fixed interval, AppleScript has an "on idle" event but doesn't seem to have an "on timeout" or "on delay" event.

So, the result is that (on my box) it refreshes at odd intervals, every 20-60 seconds or so.

OSXHints doesn't really have a place to submit binaries, so drop me a note to my username at mac.com and I'll reply with an executable for you to play with.



[ Reply to This | # ]