Author Topic: Brightness Control  (Read 5804 times)

cortez

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • http://www.omegamoon.com
Brightness Control
« on: October 16, 2007, 06:01:10 am »
It's kind of irritating that a lot of distributions lack working brightness adjustment these days, while that's the most simple way of conserving the battery.
Since debian also lacks this control using Fn-3 and Fn-4, I thought I'd give it a try myself. Here's my solution:

First, copy the Angstrom script to /usr/bin and make it executable. The script I use is:

Code: [Select]
#!/bin/sh

# display-brightness.sh
# simple script to set display-brightness for zaurus clamshell
# author: patrick steiner <[EMAIL PROTECTED]>
# modified by: Ian Munsie <[EMAIL PROTECTED]>
# version: 1.01 | 13.07.2007 15:00

STEP=5
MIN=1

DRIVER="`ls /sys/class/backlight/|head -n 1`"
BRIGHTNESS_FILE="/sys/class/backlight/$DRIVER/brightness"
MAX_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/max_brightness`
POWER_FILE="/sys/class/backlight/$DRIVER/power"
POWER_ON=0

if [ ! -n "$1" ]; then
    echo "max / current"
    echo "$MAX_BRIGHTNESS / $ACTUAL_BRIGHTNESS"
elif [ "$1" = "up" ]; then
    #test -x /usr/bin/bl && bl on
    echo $POWER_ON >> $POWER_FILE
    ACTUAL_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/actual_brightness`
    let CURRENT_BRIGHTNESS=$ACTUAL_BRIGHTNESS+$STEP
    test "$CURRENT_BRIGHTNESS" -gt "$MAX_BRIGHTNESS" &&
CURRENT_BRIGHTNESS=$MAX_BRIGHTNESS
    echo $CURRENT_BRIGHTNESS >> $BRIGHTNESS_FILE
elif [ "$1" = "down" ]; then
    ACTUAL_BRIGHTNESS=`cat /sys/class/backlight/$DRIVER/actual_brightness`
    let CURRENT_BRIGHTNESS=$ACTUAL_BRIGHTNESS-$STEP
    test "$CURRENT_BRIGHTNESS" -lt "$MIN" && CURRENT_BRIGHTNESS=$MIN
    echo $CURRENT_BRIGHTNESS >> $BRIGHTNESS_FILE
else
    echo -e "\nUsage:\n\t `basename $0` [up | down]\n"
fi

Next, apt-get xbindkeys and xbindkeys-config

Use xbindkeys-config to assign the display-brightness script to the Fn-3 and Fn-4 using the parameters down and up respectively. Then run xbindkeys

Et voila!
[div align=\"center\"]== == == == == == == == == == == == == ==
www.omegamoon.com
Zaurus SL-C750 - Died in a dreadful coffee experiment, has a second life somewhere in the Czech Republic
Zaurus SL-C1000 - Multiboot Zubuntu, Debian, Fedora, Poky, Android and others
Zaurus SL-C3100 - Development device, currently Zubuntu 2.0
Zaurus SL-6000L - The fridge is running Zubuntu 1.0
Zaurus SL-C860 - Cacko, untouched since kindly donated, waiting for Zubuntu
== == == == == == == == == == == == == ==[/div]

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Brightness Control
« Reply #1 on: October 16, 2007, 06:07:57 am »
Wow. That's nice!

It's good to see your "decaffeinated" Z running Debian?  

I simply use the setfl script from pdaXrom and change the brightness adjustment interval from 1 to 5, then use the icewm to bind the keys.  
https://www.oesf.org/forum/index.php?act=fi...&pid=168157
« Last Edit: October 16, 2007, 06:10:53 am by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Brightness Control
« Reply #2 on: October 16, 2007, 08:52:44 am »
@cortez: so would you be interested in making sound play (through the speaker) as well?  

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

cortez

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • http://www.omegamoon.com
Brightness Control
« Reply #3 on: October 16, 2007, 03:55:06 pm »
Quote from: ZDevil
It's good to see your "decaffeinated" Z running Debian?  

I simply use the setfl script from pdaXrom and change the brightness adjustment interval from 1 to 5, then use the icewm to bind the keys.  
https://www.oesf.org/forum/index.php?act=fi...&pid=168157
Maybe I should use the search option a bit more often... Oh, and by the way, my C750 is still dead, it's my replacement C3100 that's running Debian  

Quote from: ZDevil
@cortez: so would you be interested in making sound play (through the speaker) as well?  
I'm still in the exploration-phase, so I haven't been able to test the sound I'm afraid. It's really amazing that so far everything I install seems to work. No stability problems whatsoever. Ever tried the Mozilla variant Kazehakase? Anyway, give me a bit more time, and maybe I can help.

First I have to setup a build system. What do you guys use, scratchbox?
[div align=\"center\"]== == == == == == == == == == == == == ==
www.omegamoon.com
Zaurus SL-C750 - Died in a dreadful coffee experiment, has a second life somewhere in the Czech Republic
Zaurus SL-C1000 - Multiboot Zubuntu, Debian, Fedora, Poky, Android and others
Zaurus SL-C3100 - Development device, currently Zubuntu 2.0
Zaurus SL-6000L - The fridge is running Zubuntu 1.0
Zaurus SL-C860 - Cacko, untouched since kindly donated, waiting for Zubuntu
== == == == == == == == == == == == == ==[/div]

jpmatrix

  • Hero Member
  • *****
  • Posts: 1014
    • View Profile
    • http://matrixmen.free.fr
Brightness Control
« Reply #4 on: October 16, 2007, 05:15:06 pm »
little problem again with the setfl script : my default user cannot change the brightness because it cannot access /sys/class/backlight/corgi-bl/brightness .....

should i use sudo setfl or is there a better way ?
« Last Edit: October 16, 2007, 05:15:30 pm by jpmatrix »
**Fujitsu U1010 !!!  
**ex-Zaurus SL-C3000 owner with Debian kernel 2.6.24-yonggun

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Brightness Control
« Reply #5 on: October 16, 2007, 05:33:42 pm »
Actually I find xbindkeys works better than the keys setting in IceWM. xbindkeys is totally WM-independent and it can correctly pick up the Fn key, which the .icewm/keys setting fails to bind. Now I can use [Fn]+3 & 4 to turn backlight up and down easily.  

Scratchbox seems an ideal choice. But I have yet to spare some solid time to learn the basics and get some initial practice. So for now I am still using the native toolchain to build several apps that are missing in the official feeds. The GCC 4.2.1 toolchain really rocks!  With a big (512MB) swap in both my internal CF and "external" microdrive many programs got compiled with ease.
Truly, most Debian ARM packages just work and they run faster than I assumed (after worrying so much about optimization and perfecting builds in the air  ).
As for compiling strategy, I would use whatever available in the official feeds, while compiling new stuff (missing and "experimental") and recompiling things to better the performance along the way.

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
Brightness Control
« Reply #6 on: October 16, 2007, 05:35:35 pm »
Quote from: jpmatrix
little problem again with the setfl script : my default user cannot change the brightness because it cannot access /sys/class/backlight/corgi-bl/brightness .....

should i use sudo setfl or is there a better way ?


How about:
creating a wheel group.
adding your user to the wheel group,
then visudo to set up the rights for the wheel group,
then chgrp wheel setfl
?

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

jpmatrix

  • Hero Member
  • *****
  • Posts: 1014
    • View Profile
    • http://matrixmen.free.fr
Brightness Control
« Reply #7 on: October 17, 2007, 07:27:25 am »
Quote from: ZDevil
Quote from: jpmatrix
little problem again with the setfl script : my default user cannot change the brightness because it cannot access /sys/class/backlight/corgi-bl/brightness .....

should i use sudo setfl or is there a better way ?


How about:
creating a wheel group.
adding your user to the wheel group,
then visudo to set up the rights for the wheel group,
then chgrp wheel setfl
?

well,
surprisingly, i could not create a wheel group :
addgroup failed with error code

so i decided to put a my_user NOPASSWD: ALL in sudoers for my normal user...
now sudo setfl -  is working

thanks
**Fujitsu U1010 !!!  
**ex-Zaurus SL-C3000 owner with Debian kernel 2.6.24-yonggun

Chero

  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
    • http://users.telenet.be/zaurususer/Chero
Brightness Control
« Reply #8 on: October 22, 2007, 03:52:20 am »
Related to this I'm playing with "gpe-conf" (the gpe-settings-apps)

So far I've got "date & time" , "network" (partial) , "users manager" , "usb" , "screen setup" (backlight!!), "cardinfo", "sytem info" working.

more on this later.
Chero.
HP-95LX -> HP Jornada 680 -> SL-C860 -> SL-C3100 -> Fuji u810 -> SL-C1000 -> HTC uni -> SL-C860 -> SL-C760.
March 12 2009 : Back because the Zaurus is one of a kind.
SL-C760 : pdaXrom
Pandora pre-ordered -> received and tested : great device but not my cup of tea -> sold.

jpmatrix

  • Hero Member
  • *****
  • Posts: 1014
    • View Profile
    • http://matrixmen.free.fr
Brightness Control
« Reply #9 on: October 22, 2007, 11:34:32 am »
Quote from: Chero
Related to this I'm playing with "gpe-conf" (the gpe-settings-apps)

So far I've got "date & time" , "network" (partial) , "users manager" , "usb" , "screen setup" (backlight!!), "cardinfo", "sytem info" working.

more on this later.
Chero.

would you tell us more ? what did you install actually ? are these applets or menu items ? under which window manager ?
**Fujitsu U1010 !!!  
**ex-Zaurus SL-C3000 owner with Debian kernel 2.6.24-yonggun

Chero

  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
    • http://users.telenet.be/zaurususer/Chero
Brightness Control
« Reply #10 on: October 22, 2007, 03:46:03 pm »
Quote from: jpmatrix
Quote from: Chero
Related to this I'm playing with "gpe-conf" (the gpe-settings-apps)

So far I've got "date & time" , "network" (partial) , "users manager" , "usb" , "screen setup" (backlight!!), "cardinfo", "sytem info" working.

more on this later.
Chero.

would you tell us more ? what did you install actually ? are these applets or menu items ? under which window manager ?

I compiled gpe-conf and they are menu-items. The window manager doesn't matter.
HP-95LX -> HP Jornada 680 -> SL-C860 -> SL-C3100 -> Fuji u810 -> SL-C1000 -> HTC uni -> SL-C860 -> SL-C760.
March 12 2009 : Back because the Zaurus is one of a kind.
SL-C760 : pdaXrom
Pandora pre-ordered -> received and tested : great device but not my cup of tea -> sold.

scottlfa

  • Sr. Member
  • ****
  • Posts: 281
    • View Profile
    • http://
Brightness Control
« Reply #11 on: October 25, 2007, 08:03:43 pm »
Amy chance of a deb of it? or tar ball?
"So there I was, spitting on my goldfish trying to keep it alive ..."
---------------------------------------------------------------< O >-------------------------------------------------------
Viliv N5 [Debian]
Acer One Running OSX 10.5.7 [Dell 3190 & Ram Upgraded]
SL-C1000 [ZUbuntu], JasJar [WM 6.5], Nokia N900, and Samsung Galaxy S 4G.
Sony Ux280P [Kbuntu 10.4 Lucid], PsP Go and DSi

Chero

  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
    • http://users.telenet.be/zaurususer/Chero
Brightness Control
« Reply #12 on: October 26, 2007, 02:00:42 am »
That's the plan, but the project is sleeping right now.

I have to include some config files in /etc to make everything work.

Chero
HP-95LX -> HP Jornada 680 -> SL-C860 -> SL-C3100 -> Fuji u810 -> SL-C1000 -> HTC uni -> SL-C860 -> SL-C760.
March 12 2009 : Back because the Zaurus is one of a kind.
SL-C760 : pdaXrom
Pandora pre-ordered -> received and tested : great device but not my cup of tea -> sold.

judecn

  • Newbie
  • *
  • Posts: 11
    • View Profile
Brightness Control
« Reply #13 on: November 25, 2007, 09:31:56 pm »
I think everything *except* gpe-conf and bl can be found in the feeds at the moment.  Snarfing gpe-conf from Angstrom and getting the GPE support libraries from the feeds worked for me (as well as snarfing Angstrom's bl script in /usr/bin, which really does nothing more than invokes gpe-conf).

scottlfa

  • Sr. Member
  • ****
  • Posts: 281
    • View Profile
    • http://
Brightness Control
« Reply #14 on: November 25, 2007, 11:05:01 pm »
Found this worked for me pretty well.

Code: [Select]
###########################
# xbindkeys configuration #
###########################
#
# Version: 0.1.3
#
# If you edit this, do not forget to uncomment any lines that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier (on my keyboard):
#   Control, Shift, Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#
# Another way to specifie a key is to use 'xev' and set the
# keycode with c:nnn or the modifier with m:nnn where nnn is
# the keycode or the state returned by xev
#
# This file is created by xbindkey_config
# The structure is :
# # Remark
# "command"
# m:xxx + c:xxx
# Shift+...

#keystate_numlock = enable
#keystate_scrolllock = enable
#keystate_capslock = enable

#BrDown
"/usr/bin/display-brightness.sh down"
    m:0x10 + c:12
    Mod2 + 3

#BrUp
"/usr/bin/display-brightness.sh up"
    m:0x10 + c:13
    Mod2 + 4

#Left Click
#"xmodmap -e "pointer = 1 2 3""
#    alt

#Middle Click
#"xmodmap -e "pointer = 2 3 1""
#    m:0x0 + c:68

#Right click
#"xmodmap -e "pointer = 3 1 2""
#    m:0x40 + c:105
#    control

#Backlight On
"bl on"
    m:0x10 + c:14
    Mod2 + 5

#Backlight Off
"bl off"
    m:0x10 + c:15
    Mod2 + 6

#Home Row
#Calendar
#"xfce-terminal"
#Address
#Mail
#Home
#Menu
# End of xbindkeys configuration

file is .xbindkeyrc
« Last Edit: November 25, 2007, 11:06:36 pm by scottlfa »
"So there I was, spitting on my goldfish trying to keep it alive ..."
---------------------------------------------------------------< O >-------------------------------------------------------
Viliv N5 [Debian]
Acer One Running OSX 10.5.7 [Dell 3190 & Ram Upgraded]
SL-C1000 [ZUbuntu], JasJar [WM 6.5], Nokia N900, and Samsung Galaxy S 4G.
Sony Ux280P [Kbuntu 10.4 Lucid], PsP Go and DSi