You are not logged in.

#1 2011-11-27 02:02:58

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

handler.sh permissions?

Hi all,

I've been fiddling with my handler.sh file for ages, trying to get my hotkeys on my Thinkpad X40 to work. I've finally got to the stage where the action is recognised (i.e. the "logger" message shows up in /var/log/messages.log in the below cases). However, I can't get some actions to work.

For example:

    button/screenlock*) # Fn+F3
         logger "acpid: blank screen (Fn+F3) pressed; switching display off"
         sleep 1 && xset dpms force off ;;
    button/sleep*) # Fn+F4
         logger "acpid: sleep button (Fn+F4) pressed; initiating pm-suspend"
         /usr/sbin/pm-suspend ;;

In this case, the sleep button works, and I can suspend the computer. However I cannot blank the screen with Fn+F3, although when I am in a normal terminal I can execute the above command without sudo. xset is in /usr/bin/ however, and not /usr/sbin/. I have a variety of other commands that do not also exectute for other hotkeys (cpufreq-set etc), but I'm hoping someone can give a solution to this, and it will work for all of them!

Cheers,

Ianhoolihan

Offline

#2 2011-11-27 08:11:43

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: handler.sh permissions?

The button/sleep action uses absolute paths, whereas the button/screenlock action does not?

Last edited by .:B:. (2011-11-27 08:12:08)


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#3 2011-11-27 09:56:12

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: handler.sh permissions?

Maybe you have to run xset command with su and DISPLAY. Something like tihis:

sleep 1 && DISPLAY:0.0 su -c - username  /usr/bin/xset dpms force off ;; 

If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#4 2011-11-27 20:06:59

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

Thanks for both of your replies, but neither seems to work.

Note that I can run

xset dpms force off

from the terminal, without using sudo --- but it doesn't work in the handler.sh file. Also, I did have this working about three weeks ago, but after I updated the system, the same handler.sh does not work.

Any ideas on how to fix this, or test it?

Cheers

Offline

#5 2011-11-27 20:09:13

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: handler.sh permissions?

Run acpi_lsiten and press fn+F3. Post the output.

Last edited by Shark (2011-11-27 20:09:26)


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#6 2011-11-27 20:51:28

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

acpi_listen gives:

button/screenlock SCRNLCK 00000080 00000000
button/sleep SBTN 00000080 00000000

Note that previously it was something more like those originally posted in the topic below:

https://bbs.archlinux.org/viewtopic.php?id=130121

i.e. ibm/hotkey HKEY ...

Offline

#7 2011-11-27 22:35:23

David Batson
Member
Registered: 2011-10-13
Posts: 640

Re: handler.sh permissions?

I saw this which may help set it up: https://wiki.archlinux.org/index.php/Acpid

Offline

#8 2011-11-27 22:49:47

David Batson
Member
Registered: 2011-10-13
Posts: 640

Re: handler.sh permissions?

See also this from a bug report I was involved in awhile back.  Read esp. from comment #12 onward.

https://bugzilla.gnome.org/show_bug.cgi?id=603891

Offline

#9 2011-11-28 00:11:51

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: handler.sh permissions?

ianhoolihan wrote:

However I cannot blank the screen with Fn+F3,

Because you didn't allow the connection to your X, and you didn't specify the display, and you didn't specify the path.

So what you really want is:

XAUTHORITY=/home/ianhoolihan/.Xauthority /usr/bin/xset -display :0.0 dpms force off

You need to install an RTFM interface.

Offline

#10 2011-11-28 00:22:32

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

Thanks anxrc!

Problem solved. Before I mark this topic as solved, if you could maybe give a few sentences for the newbies among the readers (me included!) that'd be much appreciated.

Ianhoolihan

Offline

#11 2011-11-28 02:22:01

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

Following on from the last bit ...

I'm still having the problem with, for example,

    video/switchmode*) # Fn+F7
        logger "acpid: Fn+F7 pressed, toggling screen"
        case "$(xrandr -q | grep LVDS1)" in
                *"+"*) ### LVDS1 is in use
                        case "$(/usr/bin/xrandr | grep VGA1)" in
                                "VGA1 connected (normal"*) ### VGA1 connected but not in use, so turn on in dual screen
                                        logger "acpid: VGA1 now being used as second screen, above LVDS1"
                                        /usr/bin/xrandr --output VGA1 --mode "1024x768" --above LVDS1;;
                                *"+"*) ### VGA1 is in use, so turn off LVDS1 and optimise VGA1
                                        logger "acpid: LVDS1 switched off and VGA1 left on"
                                        /usr/bin/xrandr --output LVDS1 --off
                                        /usr/bin/xrandr --output VGA1 --auto
                                        /usr/bin/xrandr --output VGA1 --preferred;;
                                *) ### VGA1 not connected
                                           logger "acpid: external screen not found" ;;
                        esac;;
                 "LVDS1 connected (normal"*) ### LVDS1 connected but not in use, so turn off VGA1 and turn on LVDS1
                                        logger "acpid: LVDS1 turned on, and VGA1 off"
                                        /usr/bin/xrandr --output VGA1 --off
                                        /usr/bin/xrandr --output LVDS1 --auto
                                        /usr/bin/xrandr --output LVDS1 --preferred;;
                *) ### if LVDS1 is not connected
                        logger "acpid: LVDS1 is not connected";;

which works fine as a separate script, but not as part of handler.sh. In saying that, it worked one time when I was fiddling round with it, but not again since. Given that it also worked before the last time I updated, do I maybe just need to change the permissions on the file or something similar?

Cheers

Ianhoolihan

Offline

#12 2011-12-04 08:03:56

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

Any ideas?

Offline

#13 2011-12-04 23:09:21

ianhoolihan
Member
Registered: 2011-08-20
Posts: 85

Re: handler.sh permissions?

OK, I managed to get at least some working by adding

export XAUTHORITY="$HOME/.Xauthority"
export DISPLAY=":0"

I've no idea why this works, but it does. Could someone please explain this?

Offline

Board footer

Powered by FluxBB