Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 680499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:22:47+00:00 2026-05-14T01:22:47+00:00

I’m trying to define a new URL handler under OSX that will point at

  • 0

I’m trying to define a new URL handler under OSX that will point at a python script.

I’ve wrapped the Python script up into an applet (right-clicked on the .py, and gone Open With -> Build Applet)

I’ve added the following into the applet’s Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>Do My Thing</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>dmt</string>
        </array>
    </dict>
</array>

I’ve also used the More Internet preferences pane to specify “dmt” as a protocol, but when I try to get it to link the protocol to my applet, it says that “There was a problem setting the app as the helper”

Anyone know where I should go from here?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:22:47+00:00Added an answer on May 14, 2026 at 1:22 am

    After a lot of messing around, I’ve managed to get this working under OSX…

    This is how I’m doing it:

    in the AppleScript Script Editor, write the following script:

    on open location this_URL
        do shell script "/scripts/runLocalCommand.py '" & this_URL & "'"
    end open location
    

    If you want to make sure you’re running the Python from a certain shell (in my case, I’m using tcsh generally, and have a .tcshrc file that defines some environment variables that I want to have access to) then that middle line might want to be:

    do shell script "tcsh -c \"/scripts/localCommand.py '" & this_URL & "'\""
    

    I was wanting to do all of my actual processing inside a python script – but because of the way URL handers work in OSX, they have to call an application bundle rather than a script, so doing this in AppleScript seemed to be the easiest way to do it.

    in the Script Editor, Save As an “Application Bundle”

    Find the saved Application Bundle, and Open Contents. Find the Info.plist file, and open it. Add the following:

    <key>CFBundleIdentifier</key>
    <string>com.mycompany.AppleScript.LocalCommand</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>LocalCommand</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>local</string>
        </array>
      </dict>
    </array>
    

    Just before the last two lines, which should be:

    </dict>
    </plist>
    

    There are three strings in there that might want to be changed:

    com.mycompany.AppleScript.LocalCommand
    LocalCommand
    local
    

    The third of these is the handler ID – so a URL would be local://something

    So, then this passes over to the Python script.

    This is what I’ve got for this:

    #!/usr/bin/env python
    import sys
    import urllib
    arg = sys.argv[1]
    handler, fullPath = arg.split(":", 1)
    path, fullArgs = fullPath.split("?", 1)
    action = path.strip("/")
    args = fullArgs.split("&")
    params = {}
    for arg in args:
        key, value = map(urllib.unquote, arg.split("=", 1))
        params[key] = value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.