Although it has not been updated since '09, I kept using Apple’s utility Services Manager.app as a much better alternative to the System Preferences → Keyboard → Shortcuts → Services, where the small window makes it difficult to get a quick overview and manage a long list of the existing keyboard contextual services.
Unfortunately, that app is now incompatible with Sierra.
II thought of writing a quick applescript to reproduce the old app’s functions.
This is an extract from a pbs.plist file:
This is what I have:
set pbs_file to (path to desktop as text) & "pbs.plist"
tell application "System Events"
set servicesStatusList to NSServicesStatus of (get value of contents of property list file pbs_file)
end tell
--> {|com.barebones.textwrangler - textwrangler/open file in textwrangler - openfile|:{enabled_context_menu:false, enabled_services_menu:false}, |com.apple.dictionary - look up in dictionary - dolookupservice|:{enabled_context_menu:true}, |com.apple.grab - capture screen using timer - timedselection|:{enabled_context_menu:true, enabled_services_menu:true}, |net.publicspace.abfr10 - a better finder rename 10. - openfile|:{enabled_context_menu:true, enabled_services_menu:true}, |com.lemkesoft.graphicconverter10 - graphicconverter 10: remove metadata - serviceremovemetadata|:{enabled_context_menu:false, enabled_services_menu:false}}
Note that the extracted “servicesStatusList” doesn’t preserve the XML order, but that’s not really important at this stage.
Unfortunately, I’m stack here and need help because I can’t work out how to convert the “servicesStatusList” list to a list of lists with the following format:
where:
- there is one service per row;
- the app and service names to be extracted from the service fun name string at key 1;
- the converted list be sorted by the app name.
For instance:
Please help with the conversion.
Once I have the converted list, I’ll use it as input to a Myriad Table for display and setting the services and context menu status using:
set pbs_file to (path to desktop as text) & "pbs.plist"
set s_full_name to "com.apple.Grab - Capture Screen using Timer - timedSelection"
set s_status to true -- or false
set c_status to true -- or false
ServiceAndContextMenuStatus(pbs_file, s_full_name, s_status, c_status)
on ServiceAndContextMenuStatus(pbs_file, s_full_name, s_status, c_status)
tell application "System Events"
set service_plist to (get property list item s_full_name of property list item "NSServicesStatus" of property list file pbs_file)
tell service_plist
set value of property list item "enabled_services_menu" to s_status
set value of property list item "enabled_context_menu" to c_status
end tell
end tell
do shell script " defaults read " & quoted form of POSIX path of pbs_file
end ServiceAndContextMenuStatus
Also, if there is a better way of doing it, I’m open to any suggestion.