On Thu, Mar 17, 2022 at 10:27 AM Paolo Galtieri <pgaltieri@gmail.com> wrote:
Folks,
   I have 2 laptops, one running F31 the other F34.  When I close the
lid on the F31 system it suspends as it is supposed to.  I can ping the
system and I get no response.  On the F34 system I close the lid and the
system continues running.  I can still login to the system from the
external monitor.  The power management configuration says suspend on
lid closed on both systems.  I discovered that the reason it doesn't
suspend on the F34 system is the external monitor.  My systems share an
external monitor via a kvm switch.  Depending on which system the
external monitor is connected to that system will not suspend on lid
closure.  I verified the same thing happens with the F31 system.  There
is nothing in the power management configuration that says anything
about an external devices.

Is there any way to actually suspend a laptop when the lid is closed
regardless of any external devices?

One thing I should mention is that the external monitor is directly
connected to the F34 system via an HDMI cable, it's only the keyboard
and mouse that go through the kvm switch. If I directly connect the
monitor to the F31 system, also via HDMI, then it also fails to suspend
on lid closure.

Any help is appreciated.

Paolo

This is kind of a crude way to do this, but in my case I have mine doing something that is not normally configurable.

I have rc.local enabled in systemctl, and I have these 2 lines in the file, so that the script starts on every boot up.

/root/set-cpufreq-down-on-lid-close.sh &
disown


This is the script, it runs forever, and checks the lid state every 10 seconds and then if the state changes it turns the cpus max allowed speed to their min speed (400mhz).

When the lid is opened it turns the cpus back up (3.1ghz)

If I ssh/vnc into the machine when the lid is closed I run highspeed manually to bring it back up to full power (3.1ghz).

You only need to replace the lowspeed command with the command to suspend the machine.  The laptop hardware will take care of the lid open turning it on I think so my highspeed code section won't do anything in your case.

#!/bin/bash
laststate=open
while [ true ] ; do
  lidstate=`cat /proc/acpi/button/lid/LID0/state | awk '{print $2}'`
  if [ "${lidstate}" == "open" ] && [ "${laststate}" == "closed" ] ; then
    logger -s "at `date` lid was opened - full speed"
    /usr/local/bin/highspeed
    laststate=${lidstate}
    grep -i mhz /proc/cpuinfo | logger -s
  elif [ "${lidstate}" == "closed" ] && [ "${laststate}" == "open" ] ; then
      logger -s "at `date` lid was closed - low speed"
      /usr/local/bin/lowspeed
      laststate=${lidstate}
      grep -i mhz /proc/cpuinfo | logger -s
  fi
  sleep 10
done