In KDE 5, the Activities settings had an option for overriding (among other things) what actions closing the laptop lid did, so temporarily disabling the lid switch was as simple as switching Activities.

Now, in KDE 6, Activities have been reworked and this option was removed. What is an alternative way for me to, on demand, disable the laptop lid and keep it from putting the system to sleep? And then easily re-enable it again without a reboot or logging off?

The new Activities options for disabling “automatically turning off the screen” and “automatically sleeping and locking” have no effect.

Operating System: openSUSE Tumbleweed 20240314 KDE Plasma Version: 6.0.2 KDE Frameworks Version: 6.0.0 Qt Version: 6.6.2 Kernel Version: 6.7.9-1-default (64-bit) Graphics Platform: Wayland Processors: 12 × Intel® Core™ i7-10710U CPU @ 1.10GHz Memory: 15.5 GiB of RAM Graphics Processor: Mesa Intel® UHD Graphics Manufacturer: Micro-Star International Co., Ltd. Product Name: Prestige 15 A10SC System Version: REV:1.0

  • ReversalHatchery@beehaw.org
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    8 months ago

    On systemd systems the systemd-inhibit command is supposed to make this possible. You can “inhibit” suspending, shutting down, restarting, the lid closed action itself, etc.

    However, it has a fatal flaw. It only honors inhibits of the root user. There’s more: when you inhibit sleep as root, instead of locking the screen and turning it off, it will just pop up a polkit password dialog to request permission to sleep. The screen will still drain your battery, and your account will stay opened up.

    You can work around the first issue by either
    a) creating a one liner bash script in /usr/local/bin that runs the inhibit command, and setting up sudo so that running that script does not require a password b) creating a non-script program in the same place that runs this command, setting the owner of this program file to root, and the setuid bit on it

    If you are more creative, you could also find the way to change the lid close action from a program of yours, and make a program that places some kind of UI element (maybe a taskbar widget?) on the screen with which you can quickly toggle between sleeping or just locking the screen.