Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
what is so obvious that I just can't see it?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
ecosta
Guru
Guru


Joined: 09 May 2003
Posts: 477
Location: Brussels,BE

PostPosted: Sun Jun 24, 2007 9:24 am    Post subject: what is so obvious that I just can't see it? Reply with quote

I am trying to get my display to switch off when I close the lid of my laptop.

I have installed acpid and read the Gentoo Power Management Guide.

So I made the following file and restarted acpid

/etc/acpi/actions/lm_lid.sh
Code:

#!/bin/bash

# lid button pressed/released event handler
#test -x /usr/sbin/laptop_mode && /usr/sbin/laptop_mode auto

if grep -q open /proc/acpi/button/lid/LID/state
then
  logger "acpid: received an open lid action request"
  /usr/bin/xset -display :0.0 dpms force on
else
  logger "acpid: received a close lid action request"
  /usr/bin/xset -display :0.0 dpms force off
fi


The shell script works because the acpid events show up in /var/log/messages and I can also get it working manualy.

So my question is easy. If I can run the script manually, see that it is run by acpid and be able to run the xset command as a user... why oh why won't it run the command in bash?

Many thanks for pointing out the obvious ;)
-Ed
_________________
Linux user #201331
A8N-SLI Delux / AMD64 X2 3800+ / 1024 MB RAM / 5 x 250 GB SATA RAID 1/5 / ATI Radeon X700 256MB.
Back to top
View user's profile Send private message
embobo
Guru
Guru


Joined: 19 May 2003
Posts: 311

PostPosted: Sun Jun 24, 2007 10:58 am    Post subject: Re: what is so obvious that I just can't see it? Reply with quote

ecosta wrote:
I am trying to get my display to switch off when I close the lid of my laptop.

I have installed acpid and read the Gentoo Power Management Guide.

So I made the following file and restarted acpid

/etc/acpi/actions/lm_lid.sh
Code:

#!/bin/bash

# lid button pressed/released event handler
#test -x /usr/sbin/laptop_mode && /usr/sbin/laptop_mode auto

if grep -q open /proc/acpi/button/lid/LID/state
then
  logger "acpid: received an open lid action request"
  /usr/bin/xset -display :0.0 dpms force on
else
  logger "acpid: received a close lid action request"
  /usr/bin/xset -display :0.0 dpms force off
fi


The shell script works because the acpid events show up in /var/log/messages and I can also get it working manualy.

So my question is easy. If I can run the script manually, see that it is run by acpid and be able to run the xset command as a user... why oh why won't it run the command in bash?

Many thanks for pointing out the obvious ;)
-Ed


acpid runs as root and does not have permission to access your display. You would need to set the XAUTHORITY environment variable to the correct file <foo>/.Xauthority where <foo> is the user logged in.
Back to top
View user's profile Send private message
mark_alec
Bodhisattva
Bodhisattva


Joined: 11 Sep 2004
Posts: 6066
Location: Melbourne, Australia

PostPosted: Sun Jun 24, 2007 11:53 am    Post subject: Reply with quote

Moved from Portage & Programming to Kernel & Hardware.
_________________
www.gentoo.org.au || #gentoo-au
Back to top
View user's profile Send private message
embobo
Guru
Guru


Joined: 19 May 2003
Posts: 311

PostPosted: Mon Jun 25, 2007 10:35 pm    Post subject: Reply with quote

Quote:

I had myself a nice google search and read what I could about xauth but I just can't figure out how to give root the rights to my 'screen'

Could you please show me how you would solve my problem.

I'd just like root (acpid) to be able to turn off the LCD whenever the lid is shut... so close yet so far


On my laptop I use "radeontool":

Code:

#!/bin/sh

STATE=`cat /proc/acpi/button/lid/LID/state | awk '{ print $2 }'`

case $STATE in

"open")
        radeontool light on
        chvt `cat /tmp/fgconsole.out`
        ;;

"closed")
        fgconsole > /tmp/fgconsole.out
        chvt 1
        radeontool light off
        ;;
esac


If your graphics chip is a radeon try that (emerging app-laptop/radeontool if need be).

If you have a thinkpad there are tools that do the same thing. What sort of laptop do you have?

To solve it with xset I'm guessing you need to add this to the top of your /etc/acpi/actions/lm_lid.sh (after the #! line):

Code:

XAUTHORITY=/home/foo/.Xauthority
export XAUTHORITY


where "foo" is the name of the user logged in and "/home/foo/" is their home directory.
Back to top
View user's profile Send private message
Hypnos
Advocate
Advocate


Joined: 18 Jul 2002
Posts: 2889
Location: Omnipresent

PostPosted: Mon Jun 25, 2007 10:46 pm    Post subject: Reply with quote

With my Radeon, vbetool works just as well as radeontool for turning off the display.
_________________
Personal overlay | Simple backup scheme
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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