Solved Remove suspend options (hibernate and sleep) from kde5 on FreeBSD13.0

Not sure this is the correct forum to ask this question, but i'm having a heck of time figuring out how to remove the suspend options in the leave menu of kde5 plasma. I'm finding a lot of varying information about polkit stuff which i haven't worked with before, but everything I've tried doesn't seem to have an effect and I'm not sure if it's because a lot of the things i'm finding are about archlinux and maybe they're not relevant in FreeBSD. Seems like removing these options from the kde menus should be an easy option to configure, but i've been poking around for days and haven't had much luck. Any help would be appreciated.
 
I have no KDE installed on system but found in package plasma5-plasma-desktop-5.21.5_1.txz:

Code:
grep -nr suspend usr/

usr/local/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/config/main.xml:22:
<default>suspend,hibernate,reboot,shutdown</default>

usr/local/share/plasma/plasmoids/org.kde.plasma.kickoff/contents/ui/ConfigGeneral.qml:146:
property string actions: "suspend,hibernate,reboot,shutdown"
XML:
        <entry name="systemFavorites" type="StringList">
            <label>List of system action favorites.</label>
            <default>suspend,hibernate,reboot,shutdown</default>
        </entry>
CSS:
RadioButton {
            id: powerActionsButton
            Kirigami.FormData.label: i18n("Primary actions:")
            text: i18n("Power actions")
            ButtonGroup.group: radioGroup
            property string actions: "suspend,hibernate,reboot,shutdown"
            property int index: 0
            checked: plasmoid.configuration.primaryActions == index
        }
 
What excatly did you try with polkit?
sadly too many things to remember them all exactly. The one that seemed the most promising based on date of information and how it pertained to my searches was that the launcher and lock screen and leave menu on right click of desktop (basically everywhere those options show up) will not show up if polkit says they don't have access. So i was trying to set polkit rules files for org.freedesktop.login1.suspend/hibernate based on the information i was finding, but that had no effect and i wasn't sure if it's because the information i was finding was too specific to archlinux or if it was because i was simply setting the rules incorrectly since i really haven't messed with polkit stuff before.

The bulk of information i could find seemed to be people who are missing those options and want them, not the other way around.

I did end up figuring it out though. By looking at the policy files in polkit i realized that the actions i should be looking for are org.freedesktop.consolekit.system.suspend/hibernate/hybridsleep . I ended up leaving the login1 actions in the addRule if statement even though those actions don't seem to be defined, just in case some package or something ends up defining them later. Probably unnecessary, but i figured it can't hurt.

created 51-disable-suspend.rules in /usr/local/etc/polkit-1/rules.d/
Code:
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.suspend" ||
        action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
        action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
        action.id == "org.freedesktop.consolekit.system.suspend" ||
        action.id == "org.freedesktop.consolekit.system.suspend-multiple-users" ||
        action.id == "org.freedesktop.consolekit.system.hibernate" ||
        action.id == "org.freedesktop.consolekit.system.hibernate-multiple-users" ||
        action.id == "org.freedesktop.consolekit.system.hybridsleep" ||
        action.id == "org.freedesktop.consolekit.system.hybridsleep-multiple-users")
    {
        return polkit.Result.NO;
    }
});
 
Back
Top