The current executable for kde 5 seems to be org_kde_powerdevil, which is not in the list of known desktop power management executables. Thus, acpid executes shutdown -h now.
Created attachment 490200 [details, diff] Patch to the ebuild to apply the patch for powerbtn.sh
Created attachment 490202 [details] The patch for files/ adding org_kde_powerdevil to $PMS.
Ok, patch attached. This simply adds the executable name. I might be wrong about the role of powerdevil, but as I understood it, it should be the correct executable for the purpose.
With the patch, and Plasma 5 running, the (physical) power button now doesn’t do anything at all anymore. (And without the patch, it shuts down, but without KDE being in control.)
My power button is a little too conveniently located so I set it to only lock the screen. After a recent update, this bug affected me - power button issued shutdown despite being set to lock screen in kde settings. I independently discovered the same solution as the reporter and added org_kde_powerdevil to the daemon match list ($PMS) in powerbtn.sh. I have not tested what happens if my kde settings say to shut down on button press with the patch in place.
(In reply to Navid Zamani from comment #4) > With the patch, and Plasma 5 running, the (physical) power button now > doesn’t do anything at all anymore. (And without the patch, it shuts down, > but without KDE being in control.) If powerdevil is configured correctly, I would think that this would be another bug, as then the fault lies with powerdevil. For me, the power button is still working nicely with this patch included and power devil configured to suspend the system.
WIP in developer review: https://github.com/andrey-utkin/gentoo/commits/acpid-wip-20180502 Sorry for huge delay. Will commit soon.
sys-power/acpid-2.0.29-r1.ebuild (now in tree) applies the suggested patch and should fix the issue. Also I sent Gentoo patches to upstream maintainer Ted Felix.