Author Topic: HOW TO: Brightness Buttons  (Read 3693 times)

eviLjazz

  • Full Member
  • ***
  • Posts: 116
    • View Profile
    • http://katastrophos.net/andre/blog
HOW TO: Brightness Buttons
« on: June 07, 2004, 12:34:23 am »
Hi everybody,

just stumbled over jgraves post here:
http://www.zaurususergroup.com/index.php?n...iewtopic&t=3262

It\'s very nice, but it needs xkeymouse to function properly.
I\'ve merged his scripts and got it working with the default openbox window manager. OpenBox can be configured with keymappings that can also execute apps or scripts. This is also the way changing the screen orientation works (that is: Sys_Req is triggered and openbox launches chkhinge).

Here is my merged version of jgraves\' scripts:

Code: [Select]
#!/bin/sh

# Get the current value

CURRENT_VALUE=`cat $HOME/Choices/common/backlight`

MIN_VALUE=0

MAX_VALUE=6



case "$1" in

up)

    #If it is not already at the max value, increment it one.

    if [ $CURRENT_VALUE = $MAX_VALUE ]; then

        NEW_VALUE=$(($CURRENT_VALUE))

    else

        NEW_VALUE=$(($CURRENT_VALUE+1))

    fi

   ;;

down)

    #If it is not already at the min, decrement it one and save it.

    if [ $CURRENT_VALUE = $MIN_VALUE ]; then

        NEW_VALUE=$(($CURRENT_VALUE))

    else

        NEW_VALUE=$(($CURRENT_VALUE-1))

    fi

   ;;

esac



setfl $NEW_VALUE

echo $NEW_VALUE > $HOME/Choices/common/backlight


UPDATE: I suggest using Zazz\' fl below instead of this merged script, as it is faster and doesn\'t stress the internal flash memory by writing the current brightness value over and over again.

Just save it into a file named light in /usr/local/bin and make it executable by chmod 755 /usr/local/bin/light.

You can now control the brightness level with
   light up
or
   light down

To make things work without using the terminal everytime, just add the following lines to the end of the <keyboard> element in the /etc/xdg/openbox/rc.xml (or $HOME/.config/openbox/rc.xml) file:

Code: [Select]
 

    light down

  


  

    light up

  


UPDATE: If you want to use Zazz\' fl below, just change light down to fl - and light up to fl +.

</keyboard> is the closing tag.

You\'ll need to restart either openbox or the whole X11. Simplest way is pressing CTRL-ALT-Backspace and just restarting the X11 Server via startx.
Using Fn-3 will lower the brightness, Fn-4 vice versa.

Please note, that this will only work, if you\'re using the openbox window manager. This is what comes with the default install of pdaXrom.

Regards,
evilJazz
Sharp Zaurus SL-C3200/36GB running Cacko : Fujitsu LifeBook U2010/64GB SSD running Win7 : Nokia N900 (yes, flame me.) Blog : Twitter : Trac
Quasar Media Player : QScrobbler : Enhanced audio driver and mixer for C1000/C3x00 : Unified Sharp/Tetsu/Cacko/pdaXrom Kernel 2.4.20 branch : My packages : Sources

Zumi

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • http://
HOW TO: Brightness Buttons
« Reply #1 on: June 07, 2004, 05:31:35 pm »
This is a very useful feature, handled this way. I didn\'t have time to compile xkeymouse, but this was a simple one. 8)

I hope that the pdaXrom team gathers and includes these tricks in the next release!  (maybe you should send it to them)

Anyway, thanks.
Zumi
SL-C860: pdaXrom 1.1.0beta1
SD: 1GB A-data, GPS: Haicom HI-303S, Bluetooth: Nokia DTL-1 CF, CF WiFi: ASUS SpaceLink WL-110
Browse user contributed packages for pdaXrom!

Zazz

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
HOW TO: Brightness Buttons
« Reply #2 on: June 07, 2004, 05:52:58 pm »
I really hated those awkward scripts, storing the current value on the vulnerable nand flash, etc, so I modified \'setfl\' into what I called \'fl\' which has the following usage output:

Code: [Select]
Usage: fl [-+0-6?]

   -: decrement brightness

   +: increment brightness

   0: set backlight off

   1,2,3,4,5: set intermediate brightness

   6: set maximum brightness

   ?: query current brightness value


Delete the funny script and directly bind \'fl -\' and \'fl +\' to the Fn+3/4 key combinations.

Binary and source attached.

eviLjazz

  • Full Member
  • ***
  • Posts: 116
    • View Profile
    • http://katastrophos.net/andre/blog
HOW TO: Brightness Buttons
« Reply #3 on: June 07, 2004, 09:32:06 pm »
The drain on the internal flash NAND was a problem I was thinking about before. I suggest using fl instead of light. It\'s also faster.
Zazz, btw, using labels and gotos in a high-level language as C is ugly and a no-go IMO.
Anyway, thanks for providing your tool!

I\'ve updated my article above.
Sharp Zaurus SL-C3200/36GB running Cacko : Fujitsu LifeBook U2010/64GB SSD running Win7 : Nokia N900 (yes, flame me.) Blog : Twitter : Trac
Quasar Media Player : QScrobbler : Enhanced audio driver and mixer for C1000/C3x00 : Unified Sharp/Tetsu/Cacko/pdaXrom Kernel 2.4.20 branch : My packages : Sources

Zazz

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
HOW TO: Brightness Buttons
« Reply #4 on: June 07, 2004, 10:12:33 pm »
Yes, goto\'s can result in worse code. But goto\'s can result in better code too, so what\'s the point here? ... Blaming bad code on goto\'s is silly... Goto\'s are often very useful for error cases, or odd cases that aren\'t structured and where structured constructs only result in strange and non-obvious code... So people, please don\'t vilify the poor goto...
--Linus Torvalds, 1998

eviLjazz

  • Full Member
  • ***
  • Posts: 116
    • View Profile
    • http://katastrophos.net/andre/blog
HOW TO: Brightness Buttons
« Reply #5 on: June 07, 2004, 10:31:31 pm »
Muhar  
Sharp Zaurus SL-C3200/36GB running Cacko : Fujitsu LifeBook U2010/64GB SSD running Win7 : Nokia N900 (yes, flame me.) Blog : Twitter : Trac
Quasar Media Player : QScrobbler : Enhanced audio driver and mixer for C1000/C3x00 : Unified Sharp/Tetsu/Cacko/pdaXrom Kernel 2.4.20 branch : My packages : Sources

gromituk

  • Full Member
  • ***
  • Posts: 207
    • View Profile
HOW TO: Brightness Buttons
« Reply #6 on: June 23, 2004, 12:28:50 pm »
Quote
Binary and source attached.
Hey, this looks really nice, but where exactly do I find the code?  Sorry if it's a dumb question, but I'm new!

I stumbled across this thread while looking for references to the "backlight" application behaviour.  When the backlight switches off, so do updates to the display.  I wrote a Perl script which increments a variable once per second and prints it out.  When the backlight switches off, the variable still increments but nothing prints out.  Is this intentional?

It would also be nice to make the home key suspend, perhaps in combination with shift or something to prevent it being hit accidentally.  I seem to remember this is a bit like how the Psion 3a worked!  And opening the clamshell doesn't switch on the machine.

Zazz

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
HOW TO: Brightness Buttons
« Reply #7 on: June 23, 2004, 03:08:53 pm »
Looks like the attachement didn't survive the forum transition. I have temporarily placed a copy here for download.

gromituk

  • Full Member
  • ***
  • Posts: 207
    • View Profile
HOW TO: Brightness Buttons
« Reply #8 on: June 23, 2004, 04:35:33 pm »
Brilliant.  Thanks for the quick reply.  I'll play with it when I get home.

ThC

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
    • http://
HOW TO: Brightness Buttons
« Reply #9 on: June 23, 2004, 05:30:19 pm »
What would be the file to edit to have it working with xfce4 ? does any1 have an idea ?
SL-C3000 - pdaXrom 1.1.0Beta1
SL-C860 - pdaXrom 1.1.0 RC8 (charging circuitry dead :( )
CF RamStar 512 Mb / Hitachi 4Gb microdrive (thanks to creative's muvo² :p)
SD Sandisk 1Gb / Viking 256 Mb
Linksys WCF13 CF wifi card

Anyone willing to donate for my work, please consider donate to pdaXrom and/or OE/OZ projects instead, I wouldn't have been able to do anything without them ...

zxerx

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • http://
HOW TO: Brightness Buttons
« Reply #10 on: June 23, 2004, 10:36:00 pm »
Very nice job Zazz. There's a similar thread with code at http://externe.net/zaurus/forum/viewtopic....1e23d8230cf494d, but fl is a little bit more user friendly.

The thread by jgraves seems to have gone walkabout, but the benefit of setting up the key mappings for FN-3 and FN-4 in xkeymouse is that it will work under any window manager.

Code: [Select]
# /etc/xkmc snippet
# keycode, modifier, action, action arg, extra parameters...
keycode=51, Mod2Mask, Exec, /usr/local/bin/fl -, NoFork, NoAutoRepeat
keycode=52, Mod2Mask, Exec, /usr/local/bin/fl +, NoFork, NoAutoRepeat
[span style=\'font-size:7pt;line-height:100%\']Zaurus SL-C760 :: pdaXrom 1.0.5 :: Toshiba 512Mb SD :: Hagiwara 256Mb 10Mbit/s SD :: PQI 256Mb 40x CF :: Socket Low Power 10Mb/s Ethernet CF :: Seano WiFi CF :: Xircom 56k Modem CF[/span]