Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Acpi Lid Switch
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
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Sun Jan 30, 2005 9:51 am    Post subject: HOWTO: Acpi Lid Switch Reply with quote

hi there!

I might not contribute to much in this community, but now, I have finally gotten my lid-switch to work.
(i got it working by looking around in the forumposts)

First I must say that I am by no means a programmer, I do not leave and guarantee that it will work and not damage your computer/screen. ok?!
lets go on then!

I have an Inspiron 8500 and it has a lid switch. I you have a lid switch you may try to find it in /proc/acpi/buttons/lid/LID/ this of course assumes that you have
1. ACPI enabled in the kernel.
2. that you have emerge acpid

in that directory there are a file called "state" if you do a "cat state" it should read "open" and when you press down the lidswitch it should say c"
"close"

If this is not the case, do some research and try figure it out.
For the rest of us, continue.

Now we have established that the switch is recognized in the kernel/acpi.
Lets go to /etc/acpi/events/ and open up the file: default in an texteditor (or vi, nano, mc or whatever)

add:

Code:
 
      event=button[ /]lid.*
      action=sh /etc/acpi/lid.sh   


the first line here enables wich button to do the action for. And the lid.sh is our own script.

So, let's do it.

Code:

#!/bin/sh
grep -r close /proc/acpi/button/lid/LID/state
if [ $? -eq 0 ]; then
   /usr/X11R6/bin/xset dpms force off
    else
   /usr/X11R6/bin/xset dpms force on
fi


save this code as /etc/acpi/lid.sh
chmod it executable (liek chmod 777 lid.sh or whatever makes you happy)

then do a
/etc/init.d/acpid restart
and voila, it should work

Hopefully this howto/tutorial can make someother than me happy.

happy Gentooing everybody
/CyberTron
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Sun Jan 30, 2005 7:11 pm    Post subject: Reply with quote

thank you for the very informative how-to. I was not only able to get the lid switch working on my Inspiron 9100, but I've discovered a whole treasure trove of ACPI resources in so doing.
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
Back to top
View user's profile Send private message
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Sun Jan 30, 2005 7:40 pm    Post subject: Reply with quote

nice that I could be of help. :D
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Mon Jan 31, 2005 2:08 am    Post subject: Reply with quote

Okay, here's something strange. I restart the acpid daemon and it all works, but it stops working once I log out. DId you experience this?
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
Back to top
View user's profile Send private message
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Mon Jan 31, 2005 5:33 am    Post subject: Reply with quote

yes, I noticed that too when I restarted this morning...I have no clue why!! , I will try and look into the matter later today.
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Mon Jan 31, 2005 6:26 am    Post subject: Reply with quote

I posed elsewhere as well, if that information gives you anything helpful.
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Tue Feb 01, 2005 2:58 am    Post subject: Reply with quote

So, I think I figured it out. I booted to the LiveCD and ran the following code:
Code:
dmesg | grep acpi

It spit back a few lines, among which was the kernel command line from boot. I noticed the parameter acpi=ht was added by default, and that the lid button worked when booting from the LiveCD.

I then changed my grub.conf to read as follows:
Code:
default 0
timeout 1
splashimage=(hd0,0)/grub/splash.xpm.gz

title=Gentoo Linux 2.6.10-gentoo-r6
root (hd0,0)
kernel /kernel-2.6.10-gentoo-r6 root=/dev/hda3 acpi=ht
initrd /initrd-2.6.10-gentoo-r6

Voila! It works now. This isn't a perfect answer, but it'll work for now. I'm still searching for a better way to do this, as some ACPI stuff stops working when this is done.
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
Back to top
View user's profile Send private message
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Tue Feb 01, 2005 7:44 am    Post subject: Reply with quote

I found this answer on acpi=ht

Quote:


why some things stop working with acpi=ht

ht stands for "hyper-thread". what it does is disables all acpi settings except those needed by a hyper-threading processor. whatever it is that's causing the problem apparently isn't needed by a hyper-threading processor. ;)


that is probably why the lid switch may work, and other stuff not..don't know.
keep on searching :D
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Tue Feb 01, 2005 7:53 am    Post subject: Reply with quote

look at your /var/log/acpid log file.....there are som intressting stuff there

it says that it is in fact executing the action but this line comes up:


/usr/X11R6/bin/xset: unable to open display " "

I wonder why.......anyone else has an idea?
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
truekaiser
l33t
l33t


Joined: 05 Mar 2004
Posts: 753

PostPosted: Tue Feb 01, 2005 8:30 am    Post subject: Reply with quote

cybertron wrote:
look at your /var/log/acpid log file.....there are som intressting stuff there

it says that it is in fact executing the action but this line comes up:


/usr/X11R6/bin/xset: unable to open display " "

I wonder why.......anyone else has an idea?


root isn't allowed to accsess the x server.
Back to top
View user's profile Send private message
cybertron
n00b
n00b


Joined: 30 Jan 2004
Posts: 65
Location: Sweden

PostPosted: Tue Feb 01, 2005 8:52 am    Post subject: Reply with quote

how would one solve this problem without being a security risc?

I mean 1 solution is to give root access to X which, if I understand correctly, is a security risc

is there any other solution? and if not, how do I achieve the above?
_________________
Gentoo using ~x86 branch
computer: Dell Inspiron 8500
everything working except standby/suspend
for newbie configs for gentoo/slackware: http://www.linuxportalen.info
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Tue Feb 01, 2005 4:52 pm    Post subject: Reply with quote

cybertron wrote:
I found this answer on acpi=ht

Quote:


why some things stop working with acpi=ht

ht stands for "hyper-thread". what it does is disables all acpi settings except those needed by a hyper-threading processor. whatever it is that's causing the problem apparently isn't needed by a hyper-threading processor. ;)


that is probably why the lid switch may work, and other stuff not..don't know.
keep on searching :D

I've also noticed that the entire /proc/acpi tree vanishes when acpi=ht is used, which is why nothing else works. It seems that many acpi features are handled by hardware as opposed by software with this setting.

There are some semi-secure settings with xset, at least according to the man page, but I can't get them to work once I've logged out and am back at the gdm greeter.

For instance, xset +local: seems to imply connections from any local, non-network account, and it works while I'm logged in, but once I log out, nothing.

Also, I found some nice scripts in this post, but this guy wasn't able to provide a workable laptop lid solution either.
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
Back to top
View user's profile Send private message
maiku
Guru
Guru


Joined: 24 Mar 2004
Posts: 573
Location: Long Island, NY

PostPosted: Fri Mar 18, 2005 2:03 am    Post subject: Reply with quote

cybertron wrote:
how would one solve this problem without being a security risc?

I mean 1 solution is to give root access to X which, if I understand correctly, is a security risc

is there any other solution? and if not, how do I achieve the above?
I pretty much had the same problem. I only found that putting 'su mike -c' and enclosing it in quotes worked for me. I'd like a better solution also.
_________________
Michael A. Leonetti
As warm as green tea
Back to top
View user's profile Send private message
AfroNinja
n00b
n00b


Joined: 02 May 2003
Posts: 15
Location: Albuquerque, New Mexico

PostPosted: Fri Mar 18, 2005 4:30 am    Post subject: Reply with quote

I was able to get it to work by putting xhost +local in my .profile file for each user. I just added that to /etc/skel so new users would have it too. The only downside is that it requires a user be logged in for it to work.

Additionally, the script I'm using doesn't account for mouse movement while the lid is closed -- the display comes in and stays on in that case.
_________________
"Earth's gods may sometimes be surpassed by a wise mortal."

-- HP Lovecraft, Dreamquest of Unknown Kadath (1939)
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