LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-02-2011, 03:38 AM   #16
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3

Try this. I don't guarantee it will work.
Create file /etc/acpi/events/lid-suspend. Then copy in this:
Quote:
event=button lid.*
action=/etc/acpi/actions/lid-button.sh "%e"
Now create /etc/acpi/actions/lid-button.sh and copy this in it:
Quote:
#!/bin/sh
case "$2" in
LID0) echo -n mem >/sys/power/state ;;
*) logger "ACPI action undefined: $2" ;;
esac
Make the script executable:
Quote:
chmod +x /etc/acpi/actions/lid-button.sh
If that doesn't work you could comment this passage "echo -n mem >/sys/power/state ;;" (!!! Don't comment LID0)), and put in instead this passage "pm-suspend ;;" (without quotes).

And make sure acpid daemon is runing. You can chechk, i think, by this command (it will list you a lot of services):
Quote:
service --status-all
I must warn you that this script could conflict with gnome power-manager settings.

EDIT: i forgot to ask you. Do you have in mate enabled suspend when lid is closed in power manager settings?

Last edited by Shark82; 12-02-2011 at 03:50 AM.
 
Old 12-02-2011, 10:42 AM   #17
AllanP
Member
 
Registered: Jun 2007
Location: Nanoose Bay, B.C. Canada
Distribution: Mint, Ubuntu, Fedora, Debian, Win10, Win 11
Posts: 104

Original Poster
Rep: Reputation: 15
That's what I find strange; I don't have "Power Management" in Mate, but it is set to suspend on lid close in Gnome and Gnome Classic.
And yes acpid is running.
I rebooted after each mod.


Didn't work. Just to make sure I edited the file properly; here it is as it stands:
#!/bin/sh
case "$2" in
LID0) pm-suspend ;;
*) logger "ACPI action undefined: $2" ;;
esac
 
Old 12-02-2011, 04:24 PM   #18
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
What if you change the "pm-suspend" to "usr/sbin/pm-suspend" path?
 
Old 12-02-2011, 07:53 PM   #19
AllanP
Member
 
Registered: Jun 2007
Location: Nanoose Bay, B.C. Canada
Distribution: Mint, Ubuntu, Fedora, Debian, Win10, Win 11
Posts: 104

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Shark82 View Post
What if you change the "pm-suspend" to "usr/sbin/pm-suspend" path?
I presume you mean the file " /etc/acpi/events/lid-suspend" and move to /usr/sbin. If so; no change.
By the way; thanks for all your work on this; much appreciated. I still find it weird why it works in Gnome and Classic.
I have filed a bug report.
 
Old 12-03-2011, 01:54 AM   #20
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
Sorry i didn't make it clear. You have to edit /etc/acpi/actions/lid-suspend.sh file and in it change from pm-suspend to /usr/sbin/pm-suspend. And make it sure you made this script executable.

You could also try to move /etc/acpi/actions/lid-suspend.sh to /etc/acpi/lid-suspend.sh and, again, be sure the script is executable.
Change this too /etc/acpi/events/lid-suspend from:
Quote:
event=button lid.*
action=/etc/acpi/actions/lid-button.sh "%e"
to
Quote:
event=button[ /]lid
action=/etc/acpi/actions/lid-button.sh "%e"
***be sure that you change lid-button.sh path accordingly in /etc/acpi/events/lid-suspend file.

Last edited by Shark82; 12-03-2011 at 06:14 AM.
 
Old 12-04-2011, 01:18 PM   #21
AllanP
Member
 
Registered: Jun 2007
Location: Nanoose Bay, B.C. Canada
Distribution: Mint, Ubuntu, Fedora, Debian, Win10, Win 11
Posts: 104

Original Poster
Rep: Reputation: 15
Hi Shark

Thanks for all your effort. I am going to paste all your suggestions into a doc; go back to square one and start over. My senior brain is having trouble connecting the dots. I'll get back when I've finished. I still wonder why it works in Gnome and Classic though.

Regards, Allan

OK went from start to finish. Even tried both "LID0) echo -n mem >/sys/power/state ;;" and "pm-suspend ;;" in acpi folder. Did the chmod thingy each time.
I notice in the acpi folder there is also a "lid.sh"
Attached Files
File Type: txt lid.txt (1.3 KB, 45 views)

Last edited by AllanP; 12-04-2011 at 02:58 PM.
 
Old 12-04-2011, 04:17 PM   #22
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
Tommorow i will try all suggestion i gave you on my familly's Ubuntu 10.04 which have, i think, similar if not exact acpi scripts. That way i will figure it out where i missed the point.

Don't give up we will work it out. I have archlinux which is more lucid (clean, not-preconfigured) in that way because, usually, it has vanilla packages and not all solutions that applies to archlinux applies also to Ubuntu/Mint.
 
Old 12-04-2011, 05:39 PM   #23
AllanP
Member
 
Registered: Jun 2007
Location: Nanoose Bay, B.C. Canada
Distribution: Mint, Ubuntu, Fedora, Debian, Win10, Win 11
Posts: 104

Original Poster
Rep: Reputation: 15
Actually in Ubuntu 10's I couldn't get sleep or wireless to work at all on my laptop; all fine on the PC; where I have Win7, Ubuntu 11.10, Fedora (don't use much) and Suse (likewise). Admittedly I didn't try that hard; just used Win7. That's why I got more persistent with Mint 12; everything worked outa the box; more or less.
 
Old 12-05-2011, 03:39 AM   #24
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
Try this link http://thecodecentral.com/2011/01/18...ot-working-bug

Today i will test on Ubuntu because it has very similar, if not exact, scripts as Mint.
 
Old 12-08-2011, 06:04 AM   #25
Shark82
Member
 
Registered: Sep 2010
Posts: 90

Rep: Reputation: 3
So, is this link any help to you?
 
Old 12-08-2011, 09:14 AM   #26
AllanP
Member
 
Registered: Jun 2007
Location: Nanoose Bay, B.C. Canada
Distribution: Mint, Ubuntu, Fedora, Debian, Win10, Win 11
Posts: 104

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Shark82 View Post
So, is this link any help to you?
Sorry for not getting back, but no; no difference. I can activate sleep - Quit/Suspend; close the lid and it will awaken on opening the lid.
 
Old 05-19-2012, 12:38 PM   #27
Demonos
LQ Newbie
 
Registered: Nov 2009
Location: Warsaw, Poland
Distribution: Debian Sid
Posts: 4

Rep: Reputation: 0
Smile

Quote:
Originally Posted by AllanP View Post
Hi Shark


I notice in the acpi folder there is also a "lid.sh"
Hi AllanP,

lid.sh is the script that should do the trick. Thing is that your scirpt doesn't tell system to go to suspend :-) only to blank screen.

Recently I was fighting on my Debian Sid with suspend - it did suspend on lid close, but I wanted it to suspend on lid close only when laptop was on battery and when on AC, to stay just blanked.

You may try to use part of my script.
If you want to suspend on lid close regardless if ac adapter is on or off, change the following section:

from yor current:

Quote:
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
. /usr/share/acpi-support/screenblank
fi
to:
Quote:
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ] ; then
pm-suspend
fi
If you want to suspend on lid close only when AC adpater is unplugged, use the following:

Quote:
grep -q closed /proc/acpi/button/lid/*/state

if [ $? = 0 ] ; then
grep -q 0 /sys/class/power_supply/AC/online
if [ $? = 0 ]; then
pm-suspend
fi
For me it works perfectly.

I did another thing. When AC is on, and lid is closed, I wanted to put it into suspend when unplugging the AC adapter (without opening the lid).

To get that I had to create new event to check the AC status on lid close.
In /etc/acpi/events I created file lid_ac with the following entries:
Quote:
# /etc/acpi/events/lid_ac
# Called when lid is closed and user unpluggs AC adapter
#

event=ac_adapter.*
action=/etc/acpi/lid_ac.sh
Now, you have to create the lid_ac.sh script in the actions folder (the same where lid.sh resides)

And the script in that folder is:
Quote:
#!/bin/sh

test -f /usr/share/acpi-support/state-funcs || exit 0

. /usr/share/acpi-support/power-funcs
. /usr/share/acpi-support/policy-funcs
. /etc/default/acpi-support

#[ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre
[ -x /etc/acpi/lid.sh.pre ] && /etc/acpi/lid.sh.pre

if CheckPolicy; then exit; fi

grep -q closed /proc/acpi/button/lid/*/state

if [ $? = 0 ] ; then
grep -q 0 /sys/class/power_supply/AC/online
if [ $? = 0 ]; then
pm-suspend
fi
fi
Of course you have to make it executable with chmod +x command.

I'm not a scripter and maybe it's not very elegeant solution, but it does the trick for me and I don't have to use other power managers such as xfce4-power-manager (I run Enlightenment E17)


I hope I could help somebody

Last edited by Demonos; 05-19-2012 at 02:01 PM. Reason: Some editorial changes to improve clarity
 
  


Reply



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
LXer: Ready for Gnome 3.2? no more suspend on laptop lid close LXer Syndicated Linux News 0 09-16-2011 02:41 AM
disable suspend when I close the laptop lid lindylex Debian 5 04-14-2009 08:53 AM
Suspend on lid close works in kde but not gnome. fedora core 6 on dell inspiron 5100 mikegorb Linux - Laptop and Netbook 1 01-21-2007 11:35 PM
IBM thinkpad A31p How to enable Suspend on lid close for FC4? Boomba Linux - Laptop and Netbook 1 11-07-2005 09:22 PM
Suspend to Disk problem when I close my laptop lid xbaez Mandriva 0 06-23-2004 08:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 09:39 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
Open Source Consulting | Domain Registration