RJVB / macstrop

RJVB's repository of alternative macports, with ports missing from or overriding those in the standard collection, including a set of KF5 ports.
20 stars 9 forks source link

Qt environment variables and workaround #44

Closed Tatsh closed 4 years ago

Tatsh commented 5 years ago

I am setting QT_QPA_PLATFORMTHEME globally with ~/.MacOSX/environment.plist.

I found that some Qt apps like Wireshark (which I am not installing with MacPorts due to conflicts with the original Qt 5 packages) will read the environment variables QT_QPA_PLATFORMTHEME and will either look incorrect or will crash. In general they are buggy.

The workaround for any app bundle is to set the LSEnvironment key in Info.plist:

        <key>LSEnvironment</key>
        <dict>
                <key>QT_QPA_PLATFORMTHEME</key>
                <string></string>
        </dict>

You have to force macOS to reread Info.plist. One way is to use touch(1).

RJVB commented 5 years ago

Thanks, I'm aware of this, but what do you want me to do with it? It's not something you can set through the port unless you want to force a specific platform theme on everyone.

Where does the QT_QPA_PLATFORMTHEME2 variable come from?

Tatsh commented 5 years ago

My mistake. I think I mistyped it at some point a long time ago and thought it was relevant.

I think the best solution is to provide a note about this in the Qt Portfile.

Tatsh commented 5 years ago

For KDE apps I think the best solution is to add these values to the generated Info.plist prior to installation:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>LSEnvironment</key>
        <dict>
                <key>QT_QPA_PLATFORMTHEME</key>
                <string>kde</string>
                <key>KDE_SESSION_VERSION</key>
                <string>5</string>
        </dict>
</dict>
</plist>

This could be done with /usr/libexec/PlistBuddy. Have a file with the above contents (env-vars.plist) and then run:

/usr/libexec/PlistBuddy -xc 'Merge env-vars.plist' somewhere/kate.app/Contents/Info.plist

I've been manually patching these after install.

RJVB commented 5 years ago

I'd have to put that into a variant, and I'd have to figure out a way to do this that doesn't oblige me to know exactly where each port puts its plists. That's not something very high on my lists, to be honest.

The current instructions should be clear enough that users set the variables in their environment via a 1-time edit of a single or handful of files, and to the exact values they want to set them to.

Tatsh commented 4 years ago

On macOS, this tool works. On Catalina with the release, it must be explicitly allowed in the Security section in System Preferences.