Turn off the screen when the lid is closed, and turn on the screen when the lid is opened

Not suspending, just turning off the screen, how can I do it?

Also, I found that these settings no longer work:

[Login]
HandleLidSwitch=lock
HandleLidSwitchDocked=lock
HoldoffTimeoutSec=0

maybe this can help Prevent suspend when lid close in Fedora 40 - #5 by hamrheadcorvette

Maybe there’s something wrong, I can’t get the Lid Switch event using evtest.
It works normally on Windows.

AFAIK, some of the logind.conf settings are being overwritten by GNOME’s active session. I don’t know about the HandleLidSwitch setting in particular, but you might want to take a look at the keys in gsettings schema org.gnome.settings-daemon.plugins.power.

There is no key referring to the lid switch, but maybe one of the available keys (such as power-button-action or sleep-inactive-ac-type) acts also in the event of closing the lid?

It shouldn’t be.

systemd-inhibit --list --mode=block
WHO   UID  USER  PID  COMM           WHAT                                                     WHY                       MODE 
admin 1000 admin 2234 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses block

1 inhibitors listed.