How to prevent GUI based Shutdown

With the proliferation of remote and cloud based workstations, should a user accidentally click Poweroff instead of Restart or Logout, it isn’t as easy as bending over and pressing Power button. So here you go. Makes the Poweroff GUI do nothing, but you can still Restart and Logout.


polkit.addRule(function(action, subject) {
    if ( == "org.freedesktop.login1.power-off" || == "org.freedesktop.login1.power-off-multiple-sessions") {
        return polkit.Result.NO;

    if ( == "org.freedesktop.login1.reboot" || == "org.freedesktop.login1.reboot-multiple-sessions") {
        return polkit.Result.YES;



Nice @ALan thanks

Rocky Linux i presume

1 Like