VectorLinux
July 22, 2014, 11:09:39 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1] 2
  Print  
Author Topic: Screen Brightness For Toughbook  (Read 11206 times)
gacl
Vectorite
***
Posts: 218



« on: July 25, 2008, 05:32:36 pm »

Hallu,

I have a Panasonic Toughbook CF-T5 with 5.9 on it and i can't change the screen brightness. It is normally done with Fn+F1 but it does not work. I checked the BIOS to see if i could find something helpful there but i didn't. I tried xbacklight=x (x=0 to 100) without any success. Any ideas? Does it have to do with power management? ACPI?
Logged

“Our very lives depend on the ethics of strangers, and most of us are always strangers to other people.” -- Bill Moyers
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #1 on: July 25, 2008, 05:54:16 pm »

ACPI? Maybe.
tail -f /var/log/acpid

Mash on those keys and see if there are any events showing up in that terminal.  You can write scripts that get fired off when those events are picked up. If they are picked up.
I can help you with this. I'm out of computer time for the night, but if you have events, I'll invest the time to get you going over the next few days.
Logged
gacl
Vectorite
***
Posts: 218



« Reply #2 on: July 26, 2008, 07:01:36 pm »

Nope, nothing:

Code:
[Sat Jul 26 00:29:16 2008] exiting
[Sat Jul 26 08:16:45 2008] starting up
[Sat Jul 26 08:16:45 2008] 1 rule loaded
[Sat Jul 26 08:16:49 2008] client connected from 2813[0:0]
[Sat Jul 26 08:16:49 2008] 1 client rule loaded
[Sat Jul 26 13:15:16 2008] exiting
[Sat Jul 26 15:57:48 2008] starting up
[Sat Jul 26 15:57:48 2008] 1 rule loaded
[Sat Jul 26 15:57:52 2008] client connected from 2830[0:0]
[Sat Jul 26 15:57:52 2008] 1 client rule loaded

xev shows nothing either. They are unmapped. But what whould they be mapped to?
Logged

“Our very lives depend on the ethics of strangers, and most of us are always strangers to other people.” -- Bill Moyers
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #3 on: July 26, 2008, 08:48:15 pm »

Not mapped either?  Meaning no keycode? Is there activity pressing the keys with xev? If so, good, we can map them.  If no activity.  Try checking dmesg after pressing.  Keys that send a signal that the kernel doesn't understand will have a message logged.  If no xdev activity, or dmesg...  You are out of luck unless there is a module specific to your laptop you can load.
Logged
bigpaws
Vectorian
****
Posts: 1843


« Reply #4 on: July 27, 2008, 04:30:35 am »

That problem happens with many laptops mine
included. Here is a command to set the brightness:

echo -n 50 > /proc/acpi/video/VGA/LCD/brightness

If you look at the LCD directory there will be values that
you can set it to. You can then modify the above as needed.
Key mapping is also possible.

FYI the 50 in the above command is the variable.

HTH

Bigpaws
Logged
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #5 on: July 27, 2008, 10:12:01 am »

echo -n 50 > /proc/acpi/video/VGA/LCD/brightnessd.
Correct.  Or at least for now. /proc is depreciated, and it's moved over to /sys. But we are using both for now. The paths to the brightness file vary. Depending on the system. echoing a random value to /proc/acpi/*/*/brightness will not work. The exact accepted value needs to be used. The user can view the brightness file in a text editor to find the accepted values.

The brightness file located in /sys has been evolving with each kernel release it seems. Echoing a value to it fails with the latest kernel we have available. Now the brightness values are not in percents any longer.  It is controlled by levels.  This machine has 7 levels of brightness.  So to make the display change to full brightness I have to echo a 7.

You may not have a brightness file.  It may not be supported on your machine. I "think" most intel video cards and maybe "some" others support this.  The same goes for adjusting your brightness via xbacklight. Make sure the video kernel module is loaded. This is needed.

If trying xbacklight fails, also try this in a terminal:
xrandr --output LVDS --set BACKLIGHT_CONTROL native

Don't know why, but sometimes I need to do this, depending on what kernel I am using. Then try to set your brightness to half:
xbacklight -d 0:0 -set 50

If you can change your brightness with echoing to a brightness file, or using xbacklight, life is good.  Even if your FN+Key buttons don't send a acpi event, or aren't visible to the kernel, we can always map other keys or key combinations to get the job done. 

I've written several versions of "brightness" changing scripts that might get you started if you can manually change your brightness.  One of them is somewhat "smart" and will read your available brightness levels, what level is currently used, and bump up or down according to what key is pressed.  I'm also working on a HAL powered one that does all the thinking and should work for all hardware that supports brightess, but I got bored with it, and didn't finish.
Logged
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #6 on: July 27, 2008, 10:25:10 am »

Quote
echo -n 50 > /proc/acpi/video/VGA/LCD/brightness

I once put that on a script that I mapped to a brightness key, but I don't think I was able to increase it. I mean, to check the current value, add (or subtract) 10 to it and then echo the result... I don't know enough bash for that. Instead I ended up mapping 10 keys to each of the brightness values!  Roll Eyes
Logged
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #7 on: July 27, 2008, 03:12:10 pm »

LOL! 10 keys? yikes!

I'll post this here in case it's useful to you or others.
Code:
#!/bin/sh

# by exeterdad. No license. If ya need it, use it, change it.
# Usage put in your path somewhere and name it something like brightness.sh
# Make executable (chmod +x brightness.sh)
#
# Execute like this:
# "brightness.sh BrightnessUp" to go up one level of brightness.
# "brightness.sh BrightnessDown" to go down one level of brightness.
#
# You can use a script that launches those commands when a acpi event is triggered by the
# appropriate Fn+Key, or you can map these commands to keys of your choice. (easily done with most wm's).
# But if this is the case, you will need to adjust your sudors file to give user root permission to launch
# brightness.sh. To adjust brightness root priv's are needed. This is not the case if script is triggered
# by acpi.


# Edit path to brightness file on your machine.
brightness_file="/proc/acpi/video/VGA/LCD/brightness"

levels=$(grep "levels" $brightness_file | sed 's/ /\n/g' | sort -ug | sed '/levels:/d')

currentBrightness=$(awk /current:/'{print $2}' $brightness_file)

currentBrightnessNumber=$(echo "$levels" | grep -n "$currentBrightness" | cut -f1 -d ":")
levelsindex=$(echo "$levels" | grep -n "[0-9]")

case "$*" in
   BrightnessUp)
((currentBrightnessNumber++))
#if [ $currentBright < "100" ]; then
if [ $(echo "$levelsindex" | grep "^$currentBrightnessNumber:" | cut -f2 -d ":") ]; then
newBrightness=$(echo "$levelsindex" | grep "^$currentBrightnessNumber:" | cut -f2 -d ":")
echo "$newBrightness" > $brightness_file
fi
#fi
   ;;
   BrightnessDown)
((currentBrightnessNumber--))
#if [ $lessBright => "1" ]; then
if [ $(echo "$levelsindex" | grep "^$currentBrightnessNumber:" | cut -f2 -d ":") ]; then
newBrightness=$(echo "$levelsindex" | grep "^$currentBrightnessNumber:" | cut -f2 -d ":")
echo "$newBrightness" > $brightness_file
fi
   ;;
   *)
      no_action
   ;;
esac
This reads my /proc/acpi/video/VGA/LCD/brightness.
At this moment it looks like this:
Quote
levels:  100 37 12 25 37 50 62 75 87 100
current: 12
The "levels" line shows the brightness levels (in percentages) that my hardware supports.  Note they are in no particular order, and even has duplicates. (I dunno).
The "current" line shows which level of brightness I'm currently running. I'm on 12 at the moment to save battery power.

This script will read the available brightness levels, remove the duplicates, then put them in numerical order. It also assigns a number to each level. One through whatever. Then it finds out the current level. When called BrightnessUp or down. It read current level and that "index" number. It then adds or subtracts one from that number depending on which way you want to adjust. Then it matches the new number to the brightness and echos it to the brightness file, thus making it the next level of brightness (up or down).

Unfortunately EVERYTHING brightness related on this machine (or sound levels for that matter) is handed to the OS for control (Some machines will adjust using bios only.) so it all has to be scripted.  I have a script that is triggered when the power supply is removed to set my brightness to a very low setting.  The script is also run at boot if A/C cord is unplugged. Of course it reacts the opposite if the cord is plugged in.

Hope this is helpful.

Edit: This script will absolutely not work with a brightness file located somewhere in /sys in recent kernels. The handling is completely different.
« Last Edit: July 27, 2008, 03:15:15 pm by exeterdad » Logged
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #8 on: July 27, 2008, 06:29:00 pm »

Just discovered something cool.  I dug out my HAL based brightness script and was working on it some more. With HAL, normal users can adjust brightness! How cool is that?

This script is using the brightness file in /sys.  The advantage of using HAL is that HAL does all the dirty work, so no matter where the location of the brightness file is (and it can and will vary depending on hardware), one script will work with all supported hardware without editing by the user. And apparently non-privileged users can adjust it. Can't explain it, I'm just excited.

I need to get out more often.
Logged
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #9 on: July 28, 2008, 04:08:37 am »

Thanks for the script!

Quote
This script is using the brightness file in /sys.  The advantage of using HAL is that HAL does all the dirty work, so no matter where the location of the brightness file is (and it can and will vary depending on hardware), one script will work with all supported hardware without editing by the user. And apparently non-privileged users can adjust it.

Sounds cool.
Those special keys in laptops are a pain, and I think one of the first things new users coming from Windows notice and get annoyed about.

Quote
I need to get out more often.

LOL. I know what you mean...

Logged
gacl
Vectorite
***
Posts: 218



« Reply #10 on: July 29, 2008, 10:42:32 am »

Quote
echo -n 50 > /proc/acpi/video/VGA/LCD/brightness

Nothing there. . .

Quote
The user can view the brightness file in a text editor to find the accepted values.

I don't have one of those. "Find" shows nothing.

OK, this works:

Code:
xbacklight -set X

Where X is a percentage.
According to the "man" page you can also increase and decrease by a certain percentage. For instance:

Code:
vector://home/user
root:# xbacklight
90.000000
vector://home/user
root:# xbacklight -dec 10
vector://home/user
root:# xbacklight
80.000000
vector://home/user
root:# xbacklight -inc 10
vector://home/user
root:# xbacklight
90.000000

Quote
Instead I ended up mapping 10 keys to each of the brightness values!

You are one tough cookie, aren't you? *big-eyed*

Quote
With HAL, normal users can adjust brightness!

Maybe that's the configuration on my system because i just checked and as a user i _can_ change the brightness.

Now, let's see if i can bring those brightness keys from the dead. . .
Logged

“Our very lives depend on the ethics of strangers, and most of us are always strangers to other people.” -- Bill Moyers
wcs
Packager
Vectorian
****
Posts: 1144


« Reply #11 on: July 29, 2008, 10:51:19 am »

Quote
You are one tough cookie, aren't you?

LOL. A Linux user's gotta do what a Linux user's gotta do...
We won't be deterred by these keyboards and drivers that only work on Windows!  Smiley

Quote
echo -n 50 > /proc/acpi/video/VGA/LCD/brightness

Nothing there. . .

Complete guess, but do you have acpi enabled?
Or could the file not even be named "brightness"? Check what's inside /proc/acpi. There might be something else there.

Quote
Now, let's see if i can bring those brightness keys from the dead. . .

That might be the difficult part... I cannot even know where to start if they don't show up on xev.
I would like to know the answer to this myself.
Logged
gacl
Vectorite
***
Posts: 218



« Reply #12 on: July 29, 2008, 11:31:47 am »

OK, i'm calling it quits on this. I got want i wanted which was to change the brightness. Those brightness keys don't show up anywhere (xev, dmesg, showkey). It's going to be a lot of work and i'm sort of busy. I'll map that somewhere else some day, if ever.

Thank you guys for your help.

Gus
Logged

“Our very lives depend on the ethics of strangers, and most of us are always strangers to other people.” -- Bill Moyers
exeterdad
Packager
Vectorian
****
Posts: 2046



« Reply #13 on: July 29, 2008, 12:01:28 pm »

The only ways I know of mapping keys it finding out if the key emit any kind of signal or keycode:
xev
showkey (needs to be run without using X)
Or checking dmesg after trying a key.  If the kernel can see it, and doesn't know what to do with it, it will complain here.

I believe if these three options don't work, you are out of luck unless there is a module or a driver you need loaded. If the kernel can't see it, you won't be able to do anything.

Rather then explaining everything I've learned, I'll point you to the link that I learned most of it from. Very helpful:
http://www.archlinux.it/wiki/index.php?title=Hotkeys

gacl: xbacklight controls brightness independent of methods we discussed earlier.  It can be run as normal user.  And fortunately for you, it's working! We now know we can go that route if acpi is failing you.
Can you run this command on your machine and post the output here? This command uses dbus and HAL to find your current brightness.  If needed modules are loaded, and you have a brightness setting, HAL will find it. I suspect it won't work, but just in case?
Code:
dbus-send --system --print-reply --dest="org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer_backlight" "org.freedesktop.Hal.Device.LaptopPanel.GetBrightness"

Don't give up on mapping.  It can be VERY simple. In XFCE:
Menu Button > Settings >  Keyboard Settings > Shortcuts tab

You just type the xbacklight command you want. Then press the key you want to use and your golden.
Logged
rbistolfi
Packager
Vectorian
****
Posts: 2276


« Reply #14 on: July 29, 2008, 12:38:47 pm »

xbindkeys could be of help here.
Logged

"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!