Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Kill acpid first during shutdown
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Drkg4b
n00b
n00b


Joined: 07 Aug 2006
Posts: 42
Location: Italy

PostPosted: Fri Jan 25, 2013 1:25 pm    Post subject: Kill acpid first during shutdown Reply with quote

Hi all,

when I shutdown my laptop I need to wait for acpid to be killed (which happens after a while) before closing the lid or it will suspend to ram. I was wandering if it is safe to add an explicit kill for acpid in the shutdown runlevel script or if there are other ways.
_________________
No Star Can Light Our Way In This Life Of Dark And Fear
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Fri Jan 25, 2013 8:57 pm    Post subject: Re: Kill acpid first during shutdown Reply with quote

Drkg4b wrote:
Hi all,

when I shutdown my laptop I need to wait for acpid to be killed (which happens after a while) before closing the lid or it will suspend to ram. I was wandering if it is safe to add an explicit kill for acpid in the shutdown runlevel script or if there are other ways.


I went the other way, I have configured acpid so that it suspends to RAM on lid closing not immediately, but after 30 sec (or so) delay. This way it has time to shutdown, if I had called shutdown before slamming lid, and as well does not suspend if I open the lid right away after closer. The last is particularly important for me, since on lid closure my setup both suspends to RAM and writes hybernate image, so delay avoids unnecessary writes.
Back to top
View user's profile Send private message
Drkg4b
n00b
n00b


Joined: 07 Aug 2006
Posts: 42
Location: Italy

PostPosted: Sat Jan 26, 2013 11:44 am    Post subject: Reply with quote

This is a very good idea I didn't thought of! Thank you, I'll check out how to delay the suspend to ram after closing the lid!
Thanks again!
_________________
No Star Can Light Our Way In This Life Of Dark And Fear
Back to top
View user's profile Send private message
Drkg4b
n00b
n00b


Joined: 07 Aug 2006
Posts: 42
Location: Italy

PostPosted: Wed Feb 06, 2013 1:45 pm    Post subject: Reply with quote

Here is my solution, thanks to your advice I wrote this

Code:
if [ "$(pidof shutdown)" ]; then
    sleep 60
else
    echo 'mem' > /sys/power/state
fi


Its very simple and maybe can be improved with something like

Code:
[[ ! $(pidof shutdown) ]] && echo 'mem' > /sys/power/state


but I have not tested the last one.
_________________
No Star Can Light Our Way In This Life Of Dark And Fear
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Wed Feb 06, 2013 5:59 pm    Post subject: Reply with quote

Drkg4b wrote:
This is a very good idea I didn't thought of! Thank you, I'll check out how to delay the suspend to ram after closing the lid!
Thanks again!


This is what I have in /etc/acpi/lidbtn.sh (on my machine lid open and lid closed produces the same ACPI event, so I have to check the current state)

Code:

#!/bin/bash

lid_state=/proc/acpi/button/lid/LID/state

test -e $lid_state || exit 0

if grep -q closed $lid_state ; then
#Often, we shutdown or hibernate and then immediately close lid.
#Try to sleep to let these processes finish
   sleep 30s
# Lid could have been open back during this wait
   if grep -q closed $lid_state ; then
      logger "lid closed -> suspending"
      /usr/sbin/hibernate-s2both
   fi
else
   logger "lid opened -> resuming"
fi


which is activated as

Code:



case "$group" in
        button)
                case $action in
                        power)
                                /sbin/shutdown -h -t 5 now
                                ;;
                        #       xset dpms force off
                        lid)
                                date >> /var/log/lid
                                echo $id >> /var/log/lid
                                echo $value >> /var/log/lid
                                cat /proc/acpi/button/lid/LID/state >> /var/log/lid
                                /etc/acpi/lidbtn.sh
                                ;;

                        *)      log_unhandled $* ;;
                esac
Back to top
View user's profile Send private message
Dr.Willy
Guru
Guru


Joined: 15 Jul 2007
Posts: 547
Location: NRW, Germany

PostPosted: Thu Feb 07, 2013 8:27 pm    Post subject: Reply with quote

Well, I guess I'll add my solution too
Code:
        lid)
                case "$id" in
                open)   :;; # handled by hardware
                close)
                        runlevel | {
                                read PREVLEVEL RUNLEVEL
                                case $RUNLEVEL in
                                # multi-user mode
                                2|3|4|5)        echo mem > /sys/power/state ;;
                                # system halt | single user | reboot
                                0|1|6)          :;;
                                esac
                        }
                        ;;
                *)      log_unhandled $* ;;
                esac
                ;;
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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