>(But where should the setting be saved? "~/.profile" or a config file like "startkderc"? The latter may require modifying
If a problem is hard to solve, change the problem. It's an environment variable because that was a good tool for the problem it was solving at the time. But there's no reason why it has to stay as one. If we do end up doing this instead of doing messy things with the env, get rid of the env completely and change the logic in plasmashell/krunner to be "if (wayland || someConfig.readEntry(..)".