Laptop sleep on lid close only works once


After I put my laptop to sleep by closing the lid once, and then take it out of sleep , it doesn’t go back to sleep once the lid is closed again. This only started happening once I started using kde.

1 Like

I wrote this program to check if the lid is being detected. It is.

from time import sleep

state = "open"

while state == "open":
    f = open("/proc/acpi/button/lid/LID0/state")
    state =
    state = state.split(":")[1].strip()


Is it the desktop environment which is responsible for responding to the lid close? Why would it not be doing that?