# Suspend on lid-close not working

## potuz

Hello list. This is a newly installed Samsung laptop. When I just installed it the laptop would suspend on closing the lid. That doesn't happen anymore.  ACPI does recognize the button but when I close the lid it does not send the event:

```
$ sleep 3 && sudo cat /proc/acpi/button/lid/LID0/state 

state:      open

```

Also, if I unplug the computer, gnome-power-manager does not recognize it. It tells me that the battery is not fully charged, but it doesn' t recognize it's on battery power instead of AC. I suppose I'm not getting ACPI events, so it might be a case of this other thread https://forums.gentoo.org/viewtopic-t-920352.html but I did not want to pollute that topic. 

I am not sure when this started happening, but this machine was installed on June 30th and the first time I installed something after that was 

```
Mon Jul  8 15:25:03 2013 >>> dev-java/oracle-jre-bin-1.7.0.25

Mon Jul  8 23:43:58 2013 >>> sys-fs/fuse-2.9.2

Mon Jul  8 23:44:06 2013 >>> sys-fs/sshfs-fuse-2.4

Tue Jul 16 00:47:45 2013 >>> media-fonts/liberation-fonts-2.00.0-r1

Tue Jul 16 00:47:53 2013 >>> www-plugins/adobe-flash-11.2.202.291

Sun Jul 28 17:53:04 2013 >>> app-editors/vim-7.3.762
```

So I suppose it was after those installations that this may have started. 

The system is 

```
$ uname -a

Linux birra 3.8.13-gentoo #4 SMP Mon Aug 5 14:15:51 BRT 2013 x86_64 Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz GenuineIntel GNU/Linux
```

----------

## potuz

Some update cause I'm trying to debug this problem. It seems that ACPI does indeed read the battery and AC adapter well on the /sys system (instead of the deprecated /proc I was trying) When I unplug the computer I see

```
# cat /sys/class/power_supply/ADP1/online 

1

birra linux # cat /sys/class/power_supply/ADP1/online 

0

```

It seems that the gnome-power-manager has a bug that requires the /proc system to be present to read the battery and AC info, 

But can't find info on the close lid problem.

----------

## deper29

Hey, I recently started having this problem as well. I'm not sure when it started happening and I haven't been able to resolve it so far. Have you solved this yet?

----------

## deper29

So, I solved it shortly after. I emerged in acpid-2.0.19, and here is my lid section of /etc/acpi/default.sh. Hope it helps you.

```

 lid)

                                if [ `cat /proc/acpi/button/lid/LID/state | awk '{print $2}'` = "closed" ]

                                        then

                                                pm-suspend

                                fi

                                ;;

```

----------

## potuz

 *deper29 wrote:*   

> So, I solved it shortly after. I emerged in acpid-2.0.19, and here is my lid section of /etc/acpi/default.sh. Hope it helps you.
> 
> ```
> 
>  lid)
> ...

 

Hi thanks, I was hoping not to emerge acpid, I don't really know much but I thought the kernel should send the acpi events and gnome-power-manager should be able to handle them, it seemed to me that I didn't need to have acpid running and since it did work on this system which never had acpid I thought I might have installed something that screwed things up. Also I see you're using pm-suspend which is part of pm-utils. By the way, I have pm-utils installed pulled-in by upower, and this is because by default upower has the "deprecated"  USE on... I'll try to recompile with systemd instead of pm-utils.

----------

## potuz

I think I tracked the problem to upower

```
$ sleep 3 && !!

sleep 3 && upower --dump

Device: /org/freedesktop/UPower/devices/line_power_ADP1

  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1

  power supply:         yes

  updated:              Tue Aug  6 06:30:01 2013 (2027 seconds ago)

  has history:          no

  has statistics:       no

  line-power

    online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT1

  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT1

  vendor:               LION

  power supply:         yes

  updated:              Tue Aug  6 07:03:32 2013 (16 seconds ago)

  has history:          yes

  has statistics:       yes

  battery

    present:             yes

    rechargeable:        yes

    state:               discharging

    energy:              5.456 Wh

    energy-empty:        0 Wh

    energy-full:         6.1 Wh

    energy-full-design:  0.001 Wh

    energy-rate:         1.283 W

    voltage:             8.018 V

    time to empty:       4.3 hours

    percentage:          89.4426%

    capacity:            100%

  History (rate):

    1375783412   1.283   discharging

    1375783382   1.385   discharging

    1375783352   1.497   discharging

    1375783322   1.277   discharging

Daemon:

  daemon-version:  0.9.20

  can-suspend:     yes

  can-hibernate:   no

  on-battery:      yes

  on-low-battery:  no

  lid-is-closed:   no

  lid-is-present:  yes

  is-docked:       no

```

The lid-is-closed  is not reporting correclty. I can suspend fine by sending the signal to the dbus so I guess the problem is in recognizing the lid is closed.

----------

## potuz

Well, I recompiled upower with +systemd and the situation got worse, now upower --dump doesn't even see the lid:

```
$ upower --dump

Device: /org/freedesktop/UPower/devices/line_power_ADP1

  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/ADP1

  power supply:         yes

  updated:              Tue Aug  6 14:56:40 2013 (375 seconds ago)

  has history:          no

  has statistics:       no

  line-power

    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT1

  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT1

  vendor:               LION

  power supply:         yes

  updated:              Tue Aug  6 15:02:48 2013 (7 seconds ago)

  has history:          yes

  has statistics:       yes

  battery

    present:             yes

    rechargeable:        yes

    state:               fully-charged

    energy:              6.014 Wh

    energy-empty:        0 Wh

    energy-full:         6.1 Wh

    energy-full-design:  0.001 Wh

    energy-rate:         0 W

    voltage:             8.286 V

    percentage:          98.5902%

    capacity:            100%

Daemon:

  daemon-version:  0.9.20

  on-battery:      no

  on-low-battery:  no

  lid-is-closed:   no

  lid-is-present:  no

  is-docked:       no

```

----------

## potuz

I think it's an instance of https://bugzilla.kernel.org/show_bug.cgi?id=45461. At least all the symptoms are there. Installed acpid and checked that there are no events being fired by either closing the lid or plugging/unplugging the battery.

----------

## d_u_s_t

 *potuz wrote:*   

> Well, I recompiled upower with +systemd and the situation got worse, now upower --dump doesn't even see the lid:

 

The same here for a plain old AC powered system. Problem startet with an update to Upower 0.9.21 build with systemd useflag. Building it with -systemd solves the problem. I'm having sys-apps/systemd-204-r9 installed but I'm not using it for boot (guess that's the cause?):

```
~ $ systemd

Trying to run as user instance, but the system has not been booted with systemd.

~ $ ps ax | grep -i systemd

 5382 ?        Ss     0:00 /usr/lib/systemd/systemd-logind

 7056 ?        Sl     0:00 /usr/libexec/systemd-shim
```

----------

