Changing shortuct keys in 'Services'

Jul 03, '01 02:00:32AM

Contributed by: Algorythmn

I was reading a thread in hear talking about a problem with Services ( Mail, Grab, OmniDictionary, etc. -- Oh yeah, don't forget Quake 3 Arena [1.29f] ), namely that you can't know which Service is going to get a key if they both have it defined for a shortcut.

I ran into this problem myself today. I downloaded OmniDictionary and InstantLinks, and they both define the same two keys for the same two options ( "Lookup in Dictionary" and "Open URL" ). I prefer OminDictionary's much more featured lookup ( InstantLinks just jumps to m-w.com ), but Instant had taken over the 'Command-=' key. I tried a number of experiments to see if I could control which Service got the key. I thought perhaps the "Install" order might have something to do with it, but no cigar ...

[Editor: If you're interested in changing the keys assigned to various system services (available under the "Program menu" in the menubar), read the rest of this article for the how-to ... it's fairly easy, and definitely a handy tip!]

So I then decided to see if I could just change the key to something else. Having done some 'defaults' and .plist hacking ( not to mention messing around with Project/Interface Builder ), I figured there should be a nice, easy to spot convention for such things in Cocoa. From other tips I had read, I "Go"ed to "/System/Library/Services/" ( you don't have to have a Finder window open to use the Go command, btw. Now only if it could launch apps ... ), right-clicked on InstantLinks.service, and selected "Show Package Contents". Stepping into the Contents dir, I spotted Info.plist and dropped it on TextEdit. Now, as this was a Plist file, searching for the word "key" was going to be rather futile, so I tried searching for "=". Sure enough, an entry popped up:

[Editor's note: The angle-brackets have been replaced by square-brackets here, but they will be normal angle-brackets in the file you look at.]

[key]NSKeyEquivalent[/key]
[dict]
[key]default[/key]
[string]=[/string]
[/dict]
[key]NSMenuItem[/key]
[dict]
[key]default[/key]
[string]InstantLinks/Dictionary Lookup[/string]
[/dict]
So I ripped out this part:
[key]NSKeyEquivalent[/key]
[dict]
[key]default[/key]
[string]=[/string]
[/dict]
and saved the file. I logged out and back in, and now OmniDictionary is the only service to define 'Command-='. Of course I could have changed it to some other key, but I wanted to see if that would work. :) And since that does work, that means you can also give shortcuts to menu items that don't have them defined ...

You can also do this with apps that register themselves as Services. For example, I surfed into OmniWeb's package and looked at Info.plist. Searching for "NSKeyEquivalent" revealed OmniWeb's single menu item for Services ...

Pretty cool, ne?

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010703020032250