LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices



Reply
 
Search this Thread
Old 11-02-2006, 08:52 PM   #1
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154

Rep: Reputation: 30
laptop shuts down after suspend to ram


I added a line to acpi_handler.sh to make my computer suspend to ram. Everything works fine if I do everything manually.

Code:
echo mem > /sys/power/state
When I added this to acpi_handler.sh the laptop will go into sleep mode just fine when I close the lid. When I open the lid the computer comes out of sleep mode it switches to runlevel 0.

Here's my acpi_handler.conf

Code:
#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) /sbin/init 0
         ;;
        lid) echo mem > /sys/power/state
	 ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac
 
Old 11-03-2006, 09:29 AM   #2
titetanium
Member
 
Registered: Mar 2004
Distribution: debian testing/unstable
Posts: 68

Rep: Reputation: 16
Hi,

You'll need to touch a file in /var/run, call it s3. Next, you'll need to include in your script that whenever the lid button or Fn+f3 is pressed, that file is touched and then go to suspend. When you wake it up, it should check for the file and clear it, then wake up the desktop.

Here's an example of my suspend script:

Code:
#!/bin/sh

tmpfile=`mktemp` || exit 1

# Create a state file here and check it in /etc/acpi/powerbtn.sh so acpid
# knows that the power button press used to wake the machine shouldn't
# hibernate / shutdown / whatever
touch /var/run/S3

# Change to text mode to attempt to avoid hangs on resume with new
# radeon DRM driver
orig_vt=`fgconsole`
chvt 1

# These always seem to cause problems in whatever sleep mode
#modprobe -r ehci_hcd uhci_hcd ipw2200
modprobe -r ipw2200

# Save video state, go to S3, restore video state
videomode=`vbetool vbemode get`
vbetool vbestate save > $tmpfile
/etc/init.d/hwclock.sh stop
echo -n "mem" > /sys/power/state
/etc/init.d/hwclock.sh start
vbetool post
vbetool vbestate restore < $tmpfile
vbetool vbemode set $videomode

# Change back from text mode
chvt $orig_vt

# Can't load them in parallel with & or nasty things happen
#modprobe uhci_hcd
#modprobe ehci_hcd
modprobe ipw2200

# Give ACPI time to get the machine back up, process thermal events, etc.
sleep 10

# After coming back from S3, the battery/AC power state is often messed up.
# Try to fix it here.
### Fixed by hacking DSDT?
# rmmod battery ac
# modprobe battery
# modprobe ac

rm -f $tmpfile

# starting anacron, otherwise cron jobs can be never restarted
/etc/init.d/anacron start
And an example of my powerbutton script:
Code:
#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

if [ -f /var/run/S3 ]; then
	rm -f /var/run/S3
else
	/usr/sbin/hibernate
fi
HTH,

Titetanium
 
Old 11-03-2006, 09:40 AM   #3
titetanium
Member
 
Registered: Mar 2004
Distribution: debian testing/unstable
Posts: 68

Rep: Reputation: 16
Oops!

I see the error in your script. Your script had the power button set to go into init 0 when it is pressed. You need to use an if then else block, something like this perhaps:

Code:
#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@

case "$1" in
  button)
    case "$2" in
      power) if [ -f /var/run/S3 ]; then
	           rm -f /var/run/S3
             else /sbin/init 0
         fi         
         ;;
        lid) touch /var/run/s3 
          echo mem > /sys/power/state
	 ;;
      *) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac
I also modified your lid block to touch /var/run/s3 when the lid is closed. When the power button is pressed, it checks for the existence of that file and then clears it and wakes up the machine. Otherwise, if the file isn't there then it goes to init 0, as normal when you're trying to shutdown the machine without suspending or hibernating the machine.

HTH,

Titetanium
 
Old 11-03-2006, 03:21 PM   #4
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154

Original Poster
Rep: Reputation: 30
Thanks, adding the stuff in your last post worked perfectly.
 
Old 11-03-2006, 10:44 PM   #5
titetanium
Member
 
Registered: Mar 2004
Distribution: debian testing/unstable
Posts: 68

Rep: Reputation: 16
Thumbs up

Glad you got it sorted.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suspend to ram, doesn't wakeup, old laptop, new kernel and slack Quercus ruber Linux - Laptop and Netbook 3 09-16-2006 07:59 AM
[Help!]Laptop can not suspend to ram Crossa Linux - Laptop and Netbook 3 08-20-2006 01:29 AM
Another suspend-to-RAM problem coldsalmon Linux - Laptop and Netbook 16 08-14-2006 10:57 PM
suspend to ram works at last!!!! jwn7 Linux - Laptop and Netbook 4 03-31-2005 07:42 AM
ACPI shuts down after resume from suspend on SuSE 9.1 pmehta1613 Linux - Laptop and Netbook 0 01-18-2005 12:08 PM


All times are GMT -5. The time now is 11:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration