One of Leopard’s new features that I find most useful is a recent items stack, which puts the ‘Recent Items’ menu items under the Apple menu in the Dock. Unfortunately, it is not an official feature - for some reason it was left out - but it can still be enabled by changing the Dock’s preferences.
This script provides a simple interface to the enabling of this functionality.
(Credit to the author of the Mac OS X hint)
-- dialogDisplayer makes it easier to localize.
script dialogDisplayer
property dialogText : ""
property dialogTitle : ""
property buttonNames : {"Cancel", "OK"}
property defaultButton : "OK"
on displayDialog()
return display dialog dialogText with title dialogTitle buttons (buttonNames as list) default button defaultButton
end displayDialog
end script
tell dialogDisplayer
-- Localized Strings
set its dialogText to "Specify the section of the Dock you would like to add a Recent Items Stack to. The Stack can be removed later by dragging it from the Dock."
set its dialogTitle to "Add Recent Things Stack to Dock"
set its buttonNames to {cancelLabel:"Cancel", filesLabel:"Files", applicationsLabel:"Applications"}
set its defaultButton to its buttonNames's filesLabel
set {button returned:buttonPressed} to displayDialog()
end tell
if (buttonPressed is dialogDisplayer's buttonNames's filesLabel) then
set sectionCommand to "persistent-others"
else
set sectionCommand to "persistent-apps"
end if
do shell script "defaults write com.apple.dock " & sectionCommand & " -array-add '{\"tile-data\" = {\"list-type\" = 1;}; \"tile-type\" = \"recents-tile\";}'"
tell dialogDisplayer
-- Localized Strings
set its dialogText to "The Dock will be updated next time it opens. Relaunch the Dock?"
-- Title is kept the same
set its buttonNames to {cancelLabel:"No", relaunchLabel:"Relaunch Dock"}
set its defaultButton to its buttonNames's relaunchLabel
set {button returned:buttonPressed} to displayDialog()
end tell
if (buttonPressed is dialogDisplayer's buttonNames's relaunchLabel) then
do shell script "killall Dock"
end if
Note: this script might seem a bit convoluted - I’ve attempted to separate the localised stuff from the functional parts.