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

10.4: A simple Widget installation AppleScript System 10.4
Tiger only hintI had been using an automator script to install my downloaded widgets, but wanted to delete the zip file which the widget came in at the same time.

So I created this short AppleScript to do the job. It probably could be improved (it only deletes the zip file if it has the same file name as the widget, but with .zip on the end), but I'm pretty new to AppleScript):
tell application "Finder"
  set selectedFile to (get selection)
  set filePath to (item 1 of selectedFile as text)
  set zipFileName to filePath & ".zip"
  if zipFileName exists then
    move zipFileName to trash
  end if
  move selectedFile to folder "Widgets" of folder "Library" of startup disk
end tell
[robg adds: If you use Safari, these steps are usually automated. But this script could save some time if you use a third-party browser that doesn't install widgets automatically (or if you've disabled the feature in Safari).]
    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (4 votes cast)
 
[7,528 views]  

10.4: A simple Widget installation AppleScript | 3 comments | Create New Account
Click here to return to the '10.4: A simple Widget installation AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A simple Widget installation AppleScript
Authored by: DarthMagnus on Jun 06, '05 10:41:19AM

Unfortunately Safari does not always install the widget as it should. Often times when I download a widget in .zip format it will only unzip it and leave the widget on my desktop. The automator workflow that I had tried out would end up moving all the files on my desktop into the widgets folder. Hopefully this applescript will save me a bit of time and hassle when it comes to aquiring any new widgets from now on.



[ Reply to This | # ]
10.4: A simple Widget installation AppleScript
Authored by: ClassicUser on Jun 06, '05 08:49:33PM
Whoa - why does this script install into the Local domain "Widgets" folder? Wouldn't it be safer to install to the User domain (i.e. within the user's Home directory), instead? In other words, replace the move command with:

move selectedFile to folder "Widgets" of folder "Library" of home

Not to mention: If the user who is attempting to perform this action is not an administrative user, they won't be able to actually move a file to the Local domain at all - due to lack of permissions. Targeting the User domain is not only a better, more straightfoward, and safer idea - in this case, it's about the only location which would be possible.

[ Reply to This | # ]

10.4: A simple Widget installation AppleScript
Authored by: notverypc on Jun 22, '05 06:43:29AM
I've add a few bits to the Script posted. The following script needs to be saved as an application. The script is a droplet, so just drag your widgets on the the icon. It will then ask were you want to install the widgets. (System or User) I couldn't get the ZIP thing to work so this script only works with unzipped widgets.

on run
	display dialog "To use this installer, please drag widgets onto its Finder icon." buttons {"OK"} default button 1 
		with title "Widget Installer" with icon alias 
		((path to startup disk) & "Applications:Dashboard.app:Contents:Resources:Dashboard.icns" as string)
end run

on open draggedItems
	
	display dialog "Install Where?" buttons {"System"} & {"User"} default button 2 
		giving up after 5 with title "Widget Installer" with icon alias 
		((path to startup disk) & "Applications:Dashboard.app:Contents:Resources:Dashboard.icns" as string)
	copy the result as list to {WidgetPlace}
	
	repeat with thisFile in draggedItems
		set SystemWidget to (path to library folder as string) & "Widgets"
		set UserWidget to (path to home folder as string) & "Library:Widgets"
		
		
		if WidgetPlace is "System" then
			tell application "Finder"
				set thisFile to draggedItems
				set filePath to (item 1 of thisFile as text)
				move thisFile to SystemWidget
			end tell
			
		else
			
			try
				get UserWidget as alias
			on error
				tell application "Finder"
					set UserWidget to make new folder at (path to home folder as string) & "Library" with properties {name:"Widgets"}
				end tell
			end try
			
			tell application "Finder"
				set thisFile to draggedItems
				set filePath to (item 1 of thisFile as text)
				move thisFile to UserWidget
			end tell
			
			
		end if
	end repeat
end open


[ Reply to This | # ]