You are not logged in.

#1 2011-09-18 05:11:15

CanadaRox
Member
Registered: 2006-08-06
Posts: 19

Set backlight brightness from bash

On my laptop (Dell L501x) I am unable to use the brightness keys so I'm trying to write a bash script that I can run to change the brightness for me.  "xbacklight" is able to set (not inc or dec though) the brightness to "/sys/class/backlight/acpi_video0/brightness" but then I have to press XF86MonBrightnessDown to make the change apply.  If I press XF86MonBrightnessUp the brightness goes to 100% but "/sys/class/backlight/acpi_video0/brightness" still contains the correct value set from xbacklight.  After pressint XF86MonBrightnessUp, XF86MonBrightnessDown no longer sets the brightness correctly.

I have made two scripts that change the brightness in steps based on the value in "/sys/class/backlight/acpi_video0/brightness" however I still have to press XF86MonBrightnessDown after setting it to make the change apply.  And if I hit XF86MonBrightnessUp by mistake I have to use xbacklight manually so fix it.

Does anyone know a way I can set the brightness without having to press XF86MonBrightnessDown so that I can actually bind those keys to my scripts with xbindkeys?

(Or better yet, if anyone knows a workaround to getting the XF86 brightness keys working correctly on this laptop)

Offline

#2 2011-09-18 06:52:13

Dronte
Member
Registered: 2011-09-11
Posts: 8

Re: Set backlight brightness from bash

As u know, when you press the button, acpi event occures. There is an wiki article about this  https://wiki.archlinux.org/index.php/Acpid
This may also be usefull.
https://wiki.archlinux.org/index.php/ACPI_hotkeys

Offline

#3 2011-09-18 22:53:10

CanadaRox
Member
Registered: 2006-08-06
Posts: 19

Re: Set backlight brightness from bash

There is nothing in /etc/acpi/handler.sh that is related to the brightness keys .  I could easily create something, but that still doesn't address how to get the brightness to actually change.

Offline

#4 2011-09-19 09:53:49

Dronte
Member
Registered: 2011-09-11
Posts: 8

Re: Set backlight brightness from bash

Offline

#5 2011-09-19 11:34:47

CanadaRox
Member
Registered: 2006-08-06
Posts: 19

Re: Set backlight brightness from bash

That functions the same way as xbacklight does.  It sets the value correctly, but I still have to try to decrease the button with my keyboard before it changes.  And the extra launch options just made it so I can't change the brightness at all.

Offline

#6 2011-09-19 11:41:50

roygbiv
Member
Registered: 2011-05-18
Posts: 204

Re: Set backlight brightness from bash

Well, I made this a while ago when not using xbacklight:

#!/bin/bash
~/scripts/br

file="/sys/class/backlight/acpi_video0/brightness"
level=$(cat $file)

if [[ "$#" -eq 0 ]]; then
    cat $file
elif [[ "$1" = "-" ]]; then
    echo $(( level - 1 )) > $file
elif [[ "$1" = "+" ]]; then
    echo $(( level + 1 )) > $file
fi

It takes arguments '+' or  '-' (inc and dec), and displays the current brightness if none. I binded the "br +" and "br -" commands to some fn keys. Hope this helps.

Last edited by roygbiv (2011-09-19 11:43:38)

Offline

#7 2011-09-19 19:10:04

CanadaRox
Member
Registered: 2006-08-06
Posts: 19

Re: Set backlight brightness from bash

That still doesn't help address my problem.  I can set the brightness in the file and with xbacklight, but it wont actually change until I press XF86MonBrightnessDown.  I am trying to find out how I can make it change like when I press that key without having to press it.  xbacklight and echoing to the file doesn't actually change the brightness for me.

Offline

#8 2011-09-19 22:25:40

laloch
Member
Registered: 2010-02-04
Posts: 186

Re: Set backlight brightness from bash

There's a dell-laptop kernel module which, I guess after quick examination of it's code, should handle backlight controls on Dell notebooks.

Offline

Board footer

Powered by FluxBB