You are not logged in.

#1 2011-08-15 09:02:38

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

[SOLVED]Brightness and handler.sh

Hi

I want my laptop when on battery to decrease brigtness with xbacklight command in handler.sh and when on AC to increase. I have edited handler.sh:

battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
		    DISPLAY=:0.0 su -c - shark /usr/bin/xbacklight -dec 80 		    		    		    
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    DISPLAY=:0.0 su -c - shark /usr/bin/xbacklight -inc 80
 	      ;;

but it is not working. Wham am i missing here?

Last edited by Shark (2011-08-16 19:44:58)


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

#2 2011-08-15 11:24:59

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

Re: [SOLVED]Brightness and handler.sh

Actually, through /etc/laptop-mode/conf.d/lcd-brigtness.conf i got the desired result. But i really don't know why upper command don't work. If i change xbacklight command with vlc command then vlc start when i unlug the cable, for example.


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

#3 2011-08-15 12:58:28

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

Have you tried

DISPLAY=:0.0 su -c - shark "/usr/bin/xbacklight -inc 80"

instead of

DISPLAY=:0.0 su -c - shark /usr/bin/xbacklight -inc 80

Offline

#4 2011-08-15 19:54:49

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

Re: [SOLVED]Brightness and handler.sh

lula wrote:

Have you tried

DISPLAY=:0.0 su -c - shark "/usr/bin/xbacklight -inc 80"

instead of

DISPLAY=:0.0 su -c - shark /usr/bin/xbacklight -inc 80

Hi

I did tried it but didn't work. I have even tried it with ''


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

#5 2011-08-16 08:09:07

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

You're right, i only tried it in a shell, where it definitely needs the quotes, otherwise su complains about illegal options. When i try it in handler.sh, it doesn't work on my machine, but my battery is called BAT1 in /proc/acpi/battery and not BAT0 as in handler.sh. I'll have a closer look this evening.

Offline

#6 2011-08-16 17:31:42

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

Looking at the values present in handler.sh, i think it's better to switch brightness depending on the presence of the AC-Adapter. The working version for my machine is:

ac_adapter)                                                                                              
  case "$2" in                                                                                         
      AC|ACAD|ADP0)                                                                                    
          case "$4" in                                                                                 
              00000000)                                                                                
                  echo -n $minspeed >$setspeed                                                         
                  #/etc/laptop-mode/laptop-mode start                                                  
                  DISPLAY=:0.0 su -c - youruser "/usr/bin/xbacklight -dec 80"                            
              ;;                                                                                       
              00000001)                                                                                
                  echo -n $maxspeed >$setspeed                                                         
                  #/etc/laptop-mode/laptop-mode stop                                                   
                  DISPLAY=:0.0 su -c - youruser "/usr/bin/xbacklight -inc 80"                            
              ;;                                                                                       
          esac                                                                                         
          ;;                                                                                           
      *)  logger "ACPI action undefined: $2" ;;                                                        
  esac                                                                                                 
  ;;                                                                                                   

To get the values for your machine you can e.g. insert a

echo "$@" >>/tmp/acpi.txt

before the case "$1" in handler.sh and then tail /tmp/acpi.txt and plug in/out battery and ac-plug. Remember not to un-plug  both wink

Offline

#7 2011-08-16 17:59:13

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

Re: [SOLVED]Brightness and handler.sh

Hi
Thank you for your help but it is not working. Output of /tmp/acpi.txt:

c_adapter AC0 00000080 00000001
hotkey ATKD 00000058 00000002
processor CPU0 00000081 00000000
processor CPU1 00000081 00000000
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter AC0 00000080 00000001
ac_adapter AC0 00000080 00000000
hotkey ATKD 00000057 00000003
processor CPU0 00000081 00000000
processor CPU1 00000081 00000000
battery BAT0 00000080 00000001
ac_adapter AC0 00000080 00000001
hotkey ATKD 00000058 00000003
processor CPU0 00000081 00000000
processor CPU1 00000081 00000000
battery BAT0 00000080 00000001
battery BAT0 00000081 00000001
ac_adapter AC0 00000080 00000001

I have changed AC to AC0 as you can see that output is AC0. But the problem is somewhere else, i think, because if i put vlc command instead of xbacklight command in handler.sh everything works fine. Actually, this do just fine in handler.sh:

echo 1 > /sys/class/backlight/asus_laptop/brightness 

Thank you for help anyway.


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

#8 2011-08-16 18:17:36

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

Did you use the quotes in the statement? Does it work if you open a root-shell and enter it there?

DISPLAY=:0.0 su -c - shark "/usr/bin/xbacklight -dec 80"
DISPLAY=:0.0 su -c - shark "/usr/bin/xbacklight -inc 80"

edit: 2x the same statement wasn't intended

Last edited by lula (2011-08-16 18:20:37)

Offline

#9 2011-08-16 18:35:36

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

Re: [SOLVED]Brightness and handler.sh

In root with quoates:

No outputs have backlight property

Without:

su: invalid option -- 'd'
Try `su --help' for more information.

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

#10 2011-08-16 18:56:42

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

It seems that xbacklight does not work properly on your hardware, i think you have to find the max_brightness value for your machine (probably 7, try it out with echoeing bigger values ) as you did in:

Shark wrote:
echo 1 > /sys/class/backlight/asus_laptop/brightness 

Thank you for help anyway.

and use the echo-statements in handler.sh.

Do yourself a favor and don't copy any code from anywhere before trying if it really works. The xbacklight thing would have been a simple

xbacklight -set 100
xbacklight -set 10
xbacklight -set 100

as your user to find out that it doesn't work.

Offline

#11 2011-08-16 19:04:49

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

Re: [SOLVED]Brightness and handler.sh

That is really strange. I know that yesterday xbacklight worked if i would run it as a user (in root shell i haven't tried yesterday). I have to messed up something. Maybe because i append to kernel line:

acpi_osi=Linux 
acpi_backlight=vendor

Now i do echo thing instead xbacklight and i am happy smile

Last edited by Shark (2011-08-16 19:10:48)


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

#12 2011-08-16 19:09:08

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

Re: [SOLVED]Brightness and handler.sh

Ohh, and thanks for your help.


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

#13 2011-08-16 19:27:04

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

Shark wrote:

Maybe because i append to kernel line:

acpi_osi=Linux 
acpi_backlight=vendor
lula wrote:

Do yourself a favor ...

and change only one thing at once or make sure that your programs/scrips work as before. Things can get really complicated if you change too many things simultaneously. You might try the xbacklight version, if you change back the boot option.

Offline

#14 2011-08-16 19:44:40

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

Re: [SOLVED]Brightness and handler.sh

Heh, now that i have removed those lines everything works and xbacklight works perfectly in handler.sh:)
Sorry for troubling you and wasting your time.


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

#15 2011-08-16 20:01:03

lula
Member
Registered: 2009-07-16
Posts: 71

Re: [SOLVED]Brightness and handler.sh

Shark wrote:

Sorry for troubling you and wasting your time.

Neither trouble nor waste of time, learned something about su, my hardware ... and we could solve your problem.

Offline

Board footer

Powered by FluxBB