Recently I needed to disable the sleep button on my Fedora desktop. At first I was going to use xmodmap
but the main drawback with this method is that changes made are cleared on reboot so I would need to create a script to be run at boot to maintain my settings.
A little more googling and I found a better way of performing the change using pklocalauthority
. By creating a file “/etc/polkit-1/localauthority/50-local.d/somefile.pkla” having extension .pkla with the following entries:
[Disable suspend]
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultAny=no
ResultActive=no
ResultInctive=no
[Disable hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultAny=no
ResultActive=no
ResultInctive=no
This has been tested successfully on Fedora 20, my centos box doesn’t need this as sleep is blocked by default.
FYI: Some xmodmap commands i found useful when researching the issue.
To list all keycode mappings xmodmap -pke
To disable keyboard mapping for sleep”X86Sleep” button on my system which is mapped to “keycode 150”.xmodmap -e 'keycode 150 = NoSymbol'
Update:
After second reboot KDE ignored the localpolicy file and I had to reconfigure the sleep button within KDE. I can’t explain why it worked after first reboot, but for now am just going with redefining the button in KDE.