Re: how to run script after suspend to disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I use the acpi support under /etc/acpi/events and /etc/acpi/actions
for sleep.  The event represents a lid closure or FN-Suspend and
points at an action file. The script in the action directory tells the
system what to do.

The sleep.sh file I now use is here.If you want something to happen
after awaking from suspend mode, it should be easy to see where to put
it in.

I do not have any luck with the "hibernate" rpm or the
"gnome-power-manager" rpms, but the basic acpi method does work here.

------------------/etc/acpi/events/sleep----------------------------

# /etc/acpid/events/sleep

event=button[/]sleep
action=/etc/acpi/actions/sleep.sh %e

-----------------------------------------------------------------------------------------



------------------/etc/acpi/actions/sleep.sh
#!/bin/sh
#
# ACPI suspend to ram script
#
# http://www.kananov.com/notes/s3

#Modules to unload before suspend. This are known troublemakers!
MODULES="tg3 uhci_hcd ehci_hcd hci_usb ipw2200"

###if you use linuxant modem drivers you also need this
##MODULES="$MODULES hsfusbcd2 hsfmc97ali hsfmc97via hsfmc97ich
hsfpcibasic2 hsfserial hsfengine hsfosspec hsfsoar"



set -x

##########################################################################
# HELPER FUNCTIONS
##########################################################################

# function to remove modules
rmmodules () {

for mname in $MODULES ; do
    if grep $mname /proc/modules ; then
        rmmodule $mname
    fi
done

}

# function to remove module and all dependant modeles via recursive calls
rmmodule() {
 # module name
 m=$1
 # get list of dependant modules
 dep_m=`lsmod | grep "^$m" | awk ' { print $4}'`
 if [ "x$dep_m" != "x" ] ; then
     for m1 in $dep_m ; do
         rmmodule $m1
     done
 fi
 /sbin/rmmod $mname
 echo /sbin/modprobe $mname >> /var/run/acpi-resume-post
}


##########################################################################
# MAIN PART
##########################################################################


# source sleep config
#. /etc/sysconfig/acpi-sleep

# do not got to suspend mode if some command fails!
set -e

# sync software time to hw

hwclock --systohc

# remove problematic modules
rmmodules

# sync write cache
sync

# sleep
echo mem > /sys/power/state

# reinsert modules
if [ -f /var/run/acpi-resume-post ]; then
  sh /var/run/acpi-resume-post &> /dev/null
  rm -f /var/run/acpi-resume-post
fi

#
hwclock --hctosys

# restart HAL
service haldaemon restart


On 4/20/06, wwp <subscript@xxxxxxx> wrote:
Hello Petr,


On Wed, 19 Apr 2006 00:52:22 +0200 Petr Fischer <petr.fischer@xxxxxxxxxxxxx> wrote:

> Mikkel L. Ellertson píše v Út 18. 04. 2006 v 09:22 -0500:
> > Petr Fischer wrote:
> > > Hi,
> > >
> > > how to run my own script when starting from "hibernate" mode? (I need to
> > > restart squid and correct centrino-voltages and fan speeds).
> > >
> > > rc.local is called on "regular starting" only, right?
> > >
> > > Thanks, pf
> > >
> > You may want to take a look at /etc/sysconfig/suspend and the
> > /etc/sysconfig/suspend-scripts directory tree...
> >
>
> No similar files on my system :(

Neither here.

BTW, is pm-hibernate the right command to suspend-to-disk? Why is there no
hibernate entry in the GNOME menus?


Regards,

--
wwp


--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list





--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux