LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-12-2010, 06:22 AM   #1
GRAHAM HAMILTON
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
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
 
Old 11-12-2010, 02:12 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,152

Rep: Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309Reputation: 2309
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)
 
Old 11-22-2010, 02:24 AM   #3
GRAHAM HAMILTON
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
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
 
Old 11-22-2010, 04:29 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by GRAHAM HAMILTON View Post
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
 
Old 11-22-2010, 04:47 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by GRAHAM HAMILTON View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
brightness and screen resolution manz00r Ubuntu 18 02-27-2009 01:22 PM
Xine - Gamma / Brightness - Adjustment keithdw Linux - Software 1 03-25-2007 05:05 AM
screen adjustment with xorg radiodee1 Debian 3 01-16-2007 09:44 AM
screen adjustment leva Linux - Newbie 3 07-23-2004 12:02 AM
Screen Adjustment tautologies Linux - Software 4 10-31-2001 11:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration