Computer icon in the desktop

Hi. If you want to put the “Computer” icon on your desktop (to have a clean desk perhaps) just copy this script.


on run
	tell application "Finder"
		activate
		select startup disk
		set toolbar visible of Finder window 1 to false
		set position of Finder window 1 to {102, 106}
		set bounds of Finder window 1 to {102, 106, 501, 363}
	end tell
end run

on reopen
	run
end reopen

save it as an application with the splash disabled and set to stay open, give it your preferred name and custom icon and place it on your desktop (or wherever you want it, except the sidebar. To put a computer icon in the sidebar use the Finder prefs menu). And that’s it you got a cool “computer” icon.

P.d: Part of this script was contributed by kel.

Model: eMac G4 1.42GHz maxed out in everything
AppleScript: the one with Tiger 10.4.2
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b4) Gecko/20050718 Camino/0.9a2
Operating System: Mac OS X (10.4)

That’s a neat idea! :slight_smile: It works brilliantly on my Tiger machine, but doesn’t compile in Jaguar because the ‘toolbar visible’ property wasn’t invented then. (I don’t know if it exists in Panther or not.) If the script’s compiled in Tiger, with the ‘toolbar visible’ line in a ‘try’ block, it runs OK in Jaguar ” but obviously without hiding the toolbar.

When the computer has several disks or partitions mounted, the startup disk isn’t guaranteed to amongst those visible in the resized window. One way round this would be to select it again after you’ve set the bounds. I myself would want to resize the window by setting its ‘zoomed’ to ‘true’, so that all the partitions were visible. But that doesn’t work in Tiger, which has a bug in the ‘zoomed’ department. :frowning:

The ‘position’ of a window is included in its ‘bounds’, so you don’t need to set both.

on run
	tell application "Finder"
		activate
		select startup disk
		try
			-- Tiger (and Panther?) only:
			set toolbar visible of Finder window 1 to false
			-- To compile on any OS X system:
			-- set «class tbvi» of Finder window 1 to false
		end try
		set bounds of Finder window 1 to {102, 106, 501, 363}
		select startup disk
	end tell
end run

on reopen
	run
end reopen

Does anyone know the difference between the Finder’s ‘select’ and ‘reveal’ commands? They appear to do exactly the same thing in OS X. Previously, ‘select’ would simply select items without necessarily opening windows to reveal them.

Thanks for the suggestions. I didn’t combined to position and bounds parameters, I just hit the “record” button and moved and then resized the window, the separate parameters is what the script editor came up with when I hit the “stop” button after moving and resizing the “Computer” window. As for the select parameter. It causes the finder to select and item and open it’s container folder if it’s closed. I used it because the “open” parameter won’t work for the “Computer” folder since it’s a “virtual” location without a fixed, scriptable name (The name of the “Computer” window doesn’t appear neither in the Finder nor in the Standar suite dictionaries).
I’ll try the reveal parameter to see what’s it and post.

Model: eMac G4 1.42GHz maxed out in everything
AppleScript: the one with Tiger 10.4.2
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8b4) Gecko/20050718 Camino/0.9a2
Operating System: Mac OS X (10.4)

The reveal parameter indeed does the same as the select one.

Ah, right. That’s the down side of recording. It records what the user does manually, not what the application is supposed to achieve as a result. Back in the days of OS 8 and OS 9, it was quite common to see code like this:

tell application "Finder"
	activate
	select file "Fred"
	move selection to folder "Bert"
end tell

… instead of simply:

tell application "Finder"
	move file "Fred" to folder "Bert"
end tell

(Moving files isn’t recordable in OS X. Presumably it’s one of the tasks now subcontracted to System Events.)

I asked about this on the AppleScript-Users list a couple of days ago, but have had no replies. :frowning:

Sorry, Nigel. After reading your note, I did compare the behaviour for myself - but could see no difference at all, either. The internal mechanisms might still differ somewhat (I don’t suppose we can be really sure from where we’re standing). However, because of the way Finder behaves in OS X, the net result appears to be exactly the same. (And now you know why at least I didn’t respond before…) :wink:

I assumed it was something like that… :wink: