LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Screen Brightness Adjustment (http://www.linuxquestions.org/questions/linux-newbie-8/screen-brightness-adjustment-843867/)

GRAHAM HAMILTON 11-12-2010 06:22 AM

Screen Brightness Adjustment
 
Hello,
I have a low end 7" CnMBook running modified Debian OS. Is there any way to adjust the screen brightness, if possible by adding a Fn command Up and Down?
Many thanks,
GH

business_kid 11-12-2010 02:12 PM

finding that in my laptop the file was

BRIGHTNESS = { cat /sys/devices/virtual/backlight/acpi_video0/brightness}
BRIGHTNESS = [ $BRIGHTNESS + 1 ]
echo -n $BRIGHTNESS > /sys/devices/virtual/backlight/acpi_video0/brightness

Now I should have stopped it at 10 because 10 is max but I wasn't bothered. Some of those names may differ on your install because of a different manufacturer's dsdt (Bios file that affects acpi)

GRAHAM HAMILTON 11-22-2010 02:24 AM

Screen Brightness
 
Thanks for this - when I tried the commands I got a 'BRIGHTNESS: not found' message so I guess the Debian variable names and/or file names are different?
G

catkin 11-22-2010 04:29 AM

Quote:

Originally Posted by GRAHAM HAMILTON (Post 4166835)
Thanks for this - when I tried the commands I got a 'BRIGHTNESS: not found' message so I guess the Debian variable names and/or file names are different?
G

No, the script was malformed. Try
Code:

BRIGHTNESS=$( cat /sys/devices/virtual/backlight/acpi_video0/brightness )
BRIGHTNESS=$(( ++BRIGHTNESS ))
echo -n $BRIGHTNESS > /sys/devices/virtual/backlight/acpi_video0/brightness

Notes:
  1. For = to be an assignment operator it cannot be surrounded by spaces
  2. { } groups commands; $( ) executes command(s) and is substituted by the stdout
  3. [ ] denotes a test; $(( )) evaluates an arithmetic expression and is substituted by the result

catkin 11-22-2010 04:47 AM

Quote:

Originally Posted by GRAHAM HAMILTON (Post 4156657)
Hello,
I have a low end 7" CnMBook running modified Debian OS. Is there any way to adjust the screen brightness, if possible by adding a Fn command Up and Down?
Many thanks,
GH

Do you know which graphics chip it has? The lspci command might show. It may be that the /sys/devices/... path is influenced by the model.

It's not a popular machine so netsearching for CnMBook and brightness is not helpfule but netsearching for debian and brightness may help.

Here's a script that works on the Samsung N150:
Code:

#!/bin/bash
# increase/decrease/set/get the backlight brightness (range 0-255)
#
# 6jun10 Charles
#  * Creation by copying from http://wiki.archlinux.org/index.php/Samsung_N150#Backlight
#  * Added fullpath to setcpi so can be run by non-root users wth simple sudo.
#  * Changed adjusment AMOUNT from 8 to (current brightness / 10) + 1

# PCI device on which to operate
DEVICE=00:02.0

# Minimum backlight value reachable via "down"
MIN=1

# Default backlight level when toggling on
DEFAULT=64

#get current brightness in hex and convert to decimal
var1=`/sbin/setpci -s $DEVICE F4.B`
var1d=$((0x$var1))
let AMOUNT=1+var1d/10
case "$1" in
      up)
              #calculate new brightness
              var2=`echo "ibase=10; obase=16; a=($var1d+$AMOUNT);if (a<255) print a else print 255" | bc`
              echo "$0: increasing brightness from 0x$var1 to 0x$var2"
              /sbin/setpci -s $DEVICE F4.B=$var2
              ;;
      down)
              #calculate new brightness
              var2=`echo "ibase=10; obase=16; a=($var1d-$AMOUNT);if (a>$MIN) print a else print $MIN" | bc`
              echo "$0: decreasing brightness from 0x$var1 to 0x$var2"
              /sbin/setpci -s $DEVICE F4.B=$var2
              ;;
      set)
              #n.b. this does allow "set 0" i.e. backlight off
              echo "$0: setting brightness to 0x$2"
              /sbin/setpci -s $DEVICE F4.B=$2
              ;;
      get)
              echo "$0: current brightness is 0x$var1"
              ;;
      toggle)
              if [ $var1d -eq 0 ] ; then
                      echo "toggling up"
                      /sbin/setpci -s $DEVICE F4.B=$DEFAULT
              else
                      echo "toggling down"
                      /sbin/setpci -s $DEVICE F4.B=0
              fi
              ;;
      *)
              echo "usage: $0 {up|down|set <val>|get|toggle}"
              ;;
esac
exit 0

The PCI device path "00:02.0" and field "F4.B" are hardware dependent; the values above are for the N150 which uses the Intel GMA3150 built into the Intel NM10 (formerly Pineview) chipset.

The method to map an Fn key to call it depends on which desktop you are using. Assuming the script is /usr/local/sbin/backlight, for Xfce the method is
Code:

Menu->Settings->Keyboard->"Application Shortcuts"
    Add
        Command: sudo /usr/local/sbin/backlight up
        Shortcut: (pressed Fn+Up), got  XF86MonBrightnessUp

and similarly for down.

The sudoers file must be configured to allow the user to run /usr/local/sbin/backlight, for example by:
Code:

Cmnd_Alias NETBOOK_CMDS = /usr/local/sbin/backlight, /usr/local/sbin/rftoggle, /usr/local/sbin/cpufreq_toggle
%users ALL=(ALL) NOPASSWD: NETBOOK_CMDS



All times are GMT -5. The time now is 03:43 PM.