Cleanup previous PR

This commit is contained in:
Kovid Goyal
2022-02-06 20:49:40 +05:30
parent 89679d07ae
commit eedc849c45
3 changed files with 15 additions and 12 deletions

View File

@@ -120,15 +120,17 @@ These actions can also be executed from the command line by running::
or or
kitty +open file_or_url ... kitty +open file_or_url ...
Since macOS lacks an official interface to set default URL scheme handler, you Since macOS lacks an official interface to set default URL scheme handlers,
can set it with the following command. The first argument for kitty has a command you can use for it. The first argument for is the URL
``cocoa_set_url_handler`` is the URL scheme, and the second optional argument is scheme, and the second optional argument is the bundle id of the app, which
the bundle id of the app, which defaults to kitty's. (Restores when the second defaults to kitty, if not specified. For example:
argument is an empty string.)
.. code-block:: sh .. code-block:: sh
kitty +runpy 'from kitty.fast_data_types import cocoa_set_url_handler; print(cocoa_set_url_handler("ssh", "net.kovidgoyal.kitty"));' # Set kitty as the handler for ssh:// URLs
kitty +runpy 'from kitty.fast_data_types import cocoa_set_url_handler; import sys; cocoa_set_url_handler(*sys.argv[1:]); print("OK")' ssh
# Set someapp as the handler for xyz:// URLs
kitty +runpy 'from kitty.fast_data_types import cocoa_set_url_handler; import sys; cocoa_set_url_handler(*sys.argv[1:]); print("OK")' xyz someapp.bundle.identifier
You can customize these actions by creating a :file:`launch-actions.conf` file You can customize these actions by creating a :file:`launch-actions.conf` file
in the kitty config directory, just like in the kitty config directory, just like

View File

@@ -846,11 +846,10 @@ cocoa_set_url_handler(PyObject UNUSED *self, PyObject *args) {
identifier = [NSString stringWithUTF8String:bundle_id]; identifier = [NSString stringWithUTF8String:bundle_id];
} }
// This API has been marked as deprecated. It will need to be replaced when a new approach is available. // This API has been marked as deprecated. It will need to be replaced when a new approach is available.
if (LSSetDefaultHandlerForURLScheme((CFStringRef)scheme, (CFStringRef)identifier) == noErr) { OSStatus err = LSSetDefaultHandlerForURLScheme((CFStringRef)scheme, (CFStringRef)identifier);
Py_RETURN_TRUE; if (err == noErr) Py_RETURN_NONE;
} PyErr_Format(PyExc_OSError, "Failed to set default handler with error code: %d", err);
Py_RETURN_FALSE; return NULL;
} // autoreleasepool } // autoreleasepool
} }

View File

@@ -737,9 +737,11 @@ def cocoa_set_global_shortcut(name: str, mods: int, key: int) -> bool:
def cocoa_get_lang() -> Optional[str]: def cocoa_get_lang() -> Optional[str]:
pass pass
def cocoa_set_url_handler(url_scheme: str, bundle_id: Optional[str]) -> bool:
def cocoa_set_url_handler(url_scheme: str, bundle_id: Optional[str]) -> None:
pass pass
def locale_is_valid(name: str) -> bool: def locale_is_valid(name: str) -> bool:
pass pass