conda/menuinst

Keyboard shortcuts and function key assignment (for touchbars) established in macOS preferences are not respected

Closed this issue · 1 comments

This issue was fixed already, but I am pasting the report here for provenance and better tracking in the future.


@jaimergp, I have discovered another issue with respect to macOS integration. Keyboard shortcuts and function key assignment (for touchbars) established in macOS preferences are not respected. This is resolved by creating a symbolic link Contents/MacOS/python that points to $PREFIX/bin/python, and using this python to start the application.

For example:

/Users/rclary/Applications/Spyder.app
└── Contents
    ├── Info.plist
    ├── MacOS
    │   ├── Spyder
    │   └── python -> /Users/rclary/Library/spyder-5.4.0.dev0/envs/spyder-5.4.0.dev0/bin/python
    ├── PkgInfo
    └── Resources
        └── spyder.icns

Where the application executable, Spyder, is:

#!/bin/bash
eval "$("/Users/rclary/Library/spyder-5.4.0.dev0/_conda.exe" shell.bash activate "/Users/rclary/Library/spyder-5.4.0.dev0/envs/spyder-5.4.0.dev0")"
$(dirname $BASH_SOURCE)/python /Users/rclary/Library/spyder-5.4.0.dev0/envs/spyder-5.4.0.dev0/bin/spyder "$@"

It seems to me that this symbolic link should be created by menuinst as standard behavior (or at least an option). This is how python.app (via pythonw) works. Can this be included in your merge requests to menuinst?

Originally posted by @mrclary in spyder-ide/spyder#18870 (comment)


The issue does show up in napari. One could use pythonw (which just links to python.app/Contents/MacOS/python, which just links to /bin/python), but then python.app gets integrated to the macOS, not the user application. Application shortcuts in macOS preferences would have to use python.app rather than the user's application and "python" will show up in the menubar instead of the user's app name.

The reason is that the final application bundle executable is inside python.app. This is fine for most commandline python applications because you want "python" to integrate to macOS. For the user's application, we just need to apply the same technique, i.e. have python executable "appear" to originate from inside the user's application bundle.

The two screencasts illustrate.

Unadulterated napari does not integrate shortcuts in macOS preferences...
integration

Modified napari has improved integration with macOS...
integration-2

Originally posted by @mrclary in spyder-ide/spyder#18870 (comment)

Resolution posted in napari/packaging#59 (comment) and following comments.