Remove services on OS X

15

3

I'm looking to remove some services completely, or at least from the list in the Keyboard preference pane. I've tried:

  1. Service Scrubber. It only removes services from the menu — something you've been able to do from System Preferences since 10.6.
  2. Removing files in ~/Library/Services/ and /Library/Services/. It's just that most third party apps don't put their services there.
  3. defaults delete /Applications/SomeApp.app/Contents/Info NSServices. It does remove the services from the list in System Preferences. But it also invalidates the bundle's code signature, and the changes can get reverted by updates.

I guess you'd just have to settle for the last option, and assign new signatures with codesign when needed. But is there any easier way?

Lri

Posted 2011-03-18T09:41:05.797

Reputation: 34 501

Ah, the beauty of OS X complicating things that should be simple. – cregox – 2011-03-25T18:09:22.187

Which version of OS X are you running? The internals of OS X do tend to change quite drastically between major versions. – Majenko – 2011-03-27T19:23:05.293

5@Cawas: removing services is simple: you go to the list in System Preferences and uncheck them. What Lri wants to do, for some reason, is to remove them and making them impossible to restore. Why should it be easy to break stuff? – LaC – 2011-03-28T23:40:36.607

@LaC it's probably a matter of taste in this case. In my case I wanted good old Expose. but let me reverse your question: it is simple to add the service to that list - why shouldn't it be simple to remove it completely and keep it clean if the admin so wish? – cregox – 2011-03-28T23:52:15.943

AFAICT, it's just as simple. You add a service by putting it into Library/Services or installing an application that provides it. You remove a service by removing it from Library/Services or removing the application that provides it. – LaC – 2011-03-28T23:58:02.163

Answers

3

#!/bin/sh

applist="Path Finder
Skim
TextWrangler"
IFS=$'\n'

for appname in $applist; do
    apppath=$(mdfind -onlyin /Applications/ -onlyin ~/Applications/ \
    -onlyin /Developer/Applications/ -onlyin /System/Library/CoreServices/ \
    'kMDItemKind == Application' | grep -i "/$appname.app$" | head -1)
    echo $apppath
    date=$(date '+%y%m%d%-H%M%S')
    cp "$apppath/Contents/Info.plist" "$apppath/Contents/Info-$date.plist"
    defaults delete "$apppath/Contents/Info" NSServices
    codesign -f -s - "$apppath"
done

Lri

Posted 2011-03-18T09:41:05.797

Reputation: 34 501

Any particular Certificate Type in step 2? – Daniel Beck – 2011-06-02T18:01:32.760