Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Stop elogind suspending upon closing laptop lid
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
gddman
n00b
n00b


Joined: 11 Aug 2018
Posts: 11

PostPosted: Wed May 13, 2020 2:30 pm    Post subject: [SOLVED] Stop elogind suspending upon closing laptop lid Reply with quote

Hello, something that's been bugging me ever since switching from consolekit to elogind, is that elogind has configured it so that when I shut my laptop's lid, the system suspends.

I wouldn't mind this, but since it fails to resume property (I get a black screen upon resuming), it means if I accidentally shut down my lid, I then have to do a hard reset. I have no idea why elogind's suspend doesn't resume property, since both
Code:
s2ram
and
Code:
echo mem > /sys/power/state
resume just fine. I can confirm that it's elogind cuasing this, because if I run
Code:
loginctl suspend
it similarly fails to resume from suspend.

I have tried adding /etc/systemd/logind.conf with "HandleLidSwitch=ignore", but this failed to fix the problem, the system still goes to suspend mode when I close the laptop lid. Any ideas?

EDIT: Just fixed it. Instead of creating /etc/systemd/logind.conf, the correct file is /etc/elogind/logind.conf. Just put
Code:
HandleLidSwitch=ignore
there instead.

Last edited by gddman on Wed May 13, 2020 2:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 31446
Location: here

PostPosted: Wed May 13, 2020 2:48 pm    Post subject: Re: Stop elogind from suspending when I shut the laptop lid Reply with quote

gddman wrote:
I have tried adding /etc/systemd/logind.conf with "HandleLidSwitch=ignore", but this failed to fix the problem, the system still goes to suspend mode when I close the laptop lid. Any ideas?

If you use elogind correct place for add it is /etc/elogind/logind.conf or is a typo?
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
gddman
n00b
n00b


Joined: 11 Aug 2018
Posts: 11

PostPosted: Wed May 13, 2020 2:50 pm    Post subject: Re: Stop elogind from suspending when I shut the laptop lid Reply with quote

fedeliallalinea wrote:
gddman wrote:
I have tried adding /etc/systemd/logind.conf with "HandleLidSwitch=ignore", but this failed to fix the problem, the system still goes to suspend mode when I close the laptop lid. Any ideas?

If you use elogind correct place for add it is /etc/elogind/logind.conf or is a typo?


Yup, you're right. Putting it in /etc/elogind/logind.conf fixed it. I just assumed was in systemd without checking first, so that's my bad.
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2056
Location: United Kingdom

PostPosted: Wed May 13, 2020 6:15 pm    Post subject: Reply with quote

gddman,

Does your laptop have an NVIDIA GPU, by any chance? I had the same problem as you did and, as I don't mind the laptop suspending when I close the lid, I resolved the problem with a script 04-nvidia-drivers in the directory /lib64/elogind/system-sleep/ as listed below.

Code:
#!/bin/sh
#
# Unload nvidia modules on hibernate or suspend
# Load nvidia modules on thaw or resume

function unload_if_loaded() {
    MODULE=$1
    if lsmod | grep "$MODULE" &>/dev/null; then
        rmmod $MODULE
    fi
}

case $1/$2 in
     pre/*)
         unload_if_loaded nvidia_drm
         unload_if_loaded nvidia_modeset
         unload_if_loaded nvidia
#         echo "Suspending/Hibernating" >> /dev/null
     ;;
     post/*)
         modprobe nvidia_drm
#         echo "Resuming/Thawing" >> /dev/null
     ;;
     *)
         exit $NA
     ;;
esac


If you use KDE and also have trouble with screen corruption upon resuming this way, I had success by creating a script 02-toggle-compositing in the same directory:

Code:
#!/bin/sh
#
# Turn off compositing on hibernate or suspend
# Turn on compositing on thaw or resume

username=fitzcarraldo
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"

case $1/$2 in
     pre/*)
          su $username -c "qdbus org.kde.KWin /Compositor suspend" &
     ;;
     post/*)
          su $username -c "/usr/bin/kwin_x11 --replace" &
          su $username -c "qdbus org.kde.KWin /Compositor resume" &
     ;;
     *)
          exit $NA
     ;;
esac


Ref. (for a Gentoo installation using ConsoleKit rather than elogind, but the principle is still relevant): Gentoo Linux: A work-around to be able to Resume from Suspend to RAM when using the NVIDIA closed-source driver
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.

My blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum