Skip to content

Instantly share code, notes, and snippets.

@pmbuko
Created October 18, 2013 16:59
Show Gist options
  • Save pmbuko/7044494 to your computer and use it in GitHub Desktop.
Save pmbuko/7044494 to your computer and use it in GitHub Desktop.
An applescript url handler that opens System Preference panes passed to it. (http://yourmacguy.wordpress.com/2013/07/17/make-your-own-url-handler/)
on open location this_URL
-- passed urls should be "syspref://[PaneName]
-- or "syspref://[Pane_Name]" -- no spaces
set x to the offset of ":" in this_URL
set sp to text from (x + 3) to -1 of this_URL
set pane to do shell script "echo \"" & sp & "\" | awk '{gsub(\"_\",\"\\\\ \"); print}'"
set h to path to home folder
set home to POSIX path of h
set path_heads to {"/System/", "/", home}
set pref_pane to text from (x + 3) to -1 of this_URL
repeat with head in path_heads
set pane_path to head & "Library/PreferencePanes/" & pane & ".prefPane"
try
do shell script "open " & pane_path
exit repeat
end try
end repeat
end open location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment