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

Tidy up launchpad in Mountain Lion System 10.8
Mountain Lion's Launchpad is pretty good but it's still hard to get something out of it after you put it in if you didn't get it at the Mac App Store. If Launchpad Control is overkill for you, this might help.

Drop one or more application icons onto an AppleScript droplet created from the script below to have those items' Launchpad entries eliminated. You can drag items or be prompted to select them when the AppleScript runs if you don't want to save it as an application. There is some error checking and information in the script. It doesn't do anything to the apps themselves.

You can test it on the app itself. In AppleScript Editor, save it as an app, drag the app's icon onto Launchpad, activate Launchpad, launch the app, then drag the app's icon into the window and press return when prompted.

on open the_items
	my Lighten_LaunchPad(the_items)
end open

on Lighten_LaunchPad(the_items)
	repeat with the_item in the_items
		set the_item to the_item as alias
		--try
		tell application "Finder"
			set nameString to name of the_item
			set sost to (my get_the_name(nameString)) as string
		end tell
		display dialog "Are you sure you want to remove \"" & sost & "\" from the Launchpad? The app itself won't be deleted."
		try
			set my_command to "sqlite3 ~/Library/Application\\ Support/Dock/" & "*.db \"DELETE from apps WHERE title=" & (quoted form of sost) & ";\";osascript -e 'tell application \"Dock\" to quit'"
			do shell script my_command
		on error the error_message number the error_number
			activate
			if the error_number is not -128 then
				if the error_number is 1 then
					set the error_text to "Error: " & the error_number & ". " & "You probably have too many old versions of the LaunchPad database file." & return & return & " To fix that, move some old ones out of ~/Library/Application Support/Dock. You can safely move any file with a name that ends with \".db\" or \".db.backup\" except for the most recently modified one." & return & return & "Do you want me to open that folder for you?"
					display dialog the error_text buttons {"Yes, please open it.", "Cancel"} default button 1
					if button returned of the result is "Yes, please open it." then
						do shell script "open" & space & quoted form of POSIX path of (path to application support folder from user domain) & "Dock"
					end if
					error number -128
				else
					set the error_text to "Error: " & the error_number & ". " & the error_message
					display dialog the error_text buttons {"Cancel"} default button 1
				end if
			else
				error number -128
			end if
		end try
	end repeat
	display dialog "All done!" buttons {"OK"} default button 1
end Lighten_LaunchPad

on get_the_name(nameString)
	tell AppleScript
		set olD to text item delimiters
		set text item delimiters to "."
		set reqItem to -1
		if last item of nameString = "." then set reqItem to -2
		set theName to text item reqItem of nameString
		--try
		set theNameNoExt to ((text items 1 through (reqItem - 1) of nameString) as string)
		set text item delimiters to olD
		return {theNameNoExt}
	end tell
end get_the_name

on run
	set the_items to ((choose file) as list)
	Lighten_LaunchPad(the_items)
end run

    •    
  • Currently 2.56 / 5
  You rated: 1 / 5 (9 votes cast)
 
[6,783 views]  

Tidy up launchpad in Mountain Lion | 3 comments | Create New Account
Click here to return to the 'Tidy up launchpad in Mountain Lion' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Tidy up launchpad in Mountain Lion
Authored by: stevebr on Mar 26, '13 11:57:28AM

A while ago, I went with the opposite approach:

1. Empty the database completely as discussed here: http://www.macworld.com/article/1164600/clean_out_launchpad_completely.html
2. A spotlight search of the Applications folder for kind is Application with the condition "kMDItemCFBundleIdentifier:com.apple OR kMDItemAppStoreHasReceipt:1"
3. Add results to Launchpad by dragging the results on to the Launchpad icon in the Dock

Your method is much handier for ongoing maintenance, so thank you for that.



[ Reply to This | # ]
Tidy up launchpad in Mountain Lion
Authored by: designr on Jan 05, '14 12:45:32PM

Nevermind.

Edited on Jan 05, '14 12:47:47PM by designr



[ Reply to This | # ]
Tidy up launchpad in Mountain Lion
Authored by: llee on Jan 07, '14 02:28:27PM

The script stopped working when I upgraded to Mavericks. I think it's because there are two .db items in the Dock folder in Application Support now, so I modified the script to only use one. If you'd like to keep using it, here's a Mavericks-compatible version.

on open the_items
my Lighten_LaunchPad(the_items)
end open

on Lighten_LaunchPad(the_items)
repeat with the_item in the_items
set the_item to the_item as alias
tell application "Finder"
set nameString to name of the_item
set sost to (my get_the_name(nameString)) as string
end tell
display dialog "Are you sure you want to remove \"" & sost & "\" from the Launchpad? The app itself won't be deleted."
set the_DBs to paragraphs of (do shell script "find ~/Library/Application\\ Support/Dock -maxdepth 1 -name *.db")
set active_db to ""
repeat with i in the_DBs
if i contains "desktoppicture" then
else
set active_db to i as text
end if
end repeat
try
set my_command to "sqlite3" & space & (quoted form of active_db) & space & "\"DELETE from apps WHERE title=" & (quoted form of sost) & ";\";osascript -e 'tell application \"Dock\" to quit'"
do shell script my_command
on error the error_message number the error_number
activate
if the error_number is not -128 then
if the error_number is 1 then
set the error_text to "Error: " & the error_number & ". " & "You probably have too many old versions of the LaunchPad database file." & return & return & " To fix that, move some old ones out of ~/Library/Application Support/Dock. You can safely move any file with a name that ends with \".db\" or \".db.backup\" except for the most recently modified one." & return & return & "Do you want me to open that folder for you?"
display dialog the error_text buttons {"Yes, please open it.", "Cancel"} default button 1
if button returned of the result is "Yes, please open it." then
do shell script "open" & space & quoted form of POSIX path of (path to application support folder from user domain) & "Dock"
end if
error number -128
else
set the error_text to "Error: " & the error_number & ". " & the error_message
display dialog the error_text buttons {"Cancel"} default button 1
end if
else
error number -128
end if
end try
end repeat
display dialog "All done!" buttons {"OK"} default button 1
end Lighten_LaunchPad

on get_the_name(nameString)
tell AppleScript
set olD to text item delimiters
set text item delimiters to "."
set reqItem to -1
if last item of nameString = "." then set reqItem to -2
set theName to text item reqItem of nameString
set theNameNoExt to ((text items 1 through (reqItem - 1) of nameString) as string)
set text item delimiters to olD
return {theNameNoExt}
end tell
end get_the_name

on run
set the_items to ((choose file) as list)
Lighten_LaunchPad(the_items)
end run

Edited on Jan 07, '14 02:29:15PM by llee



[ Reply to This | # ]