backlight settings cl script

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

backlight settings cl script

#1 Post by Karl Godt »

Good day !

Today i booted my netbook to find having set a zero in

" /sys/class/backlight/acpi_video0/brightness " .

I remember iguleder had a small c binary in his squeeze dpup times nearly two years ago , but that had not been accessible for me today .

So i hug a script called " set_bl " -- if anyone discovers bugs or different paths or max values, please let me know :

Code: Select all

#!/bin/sh
# Wriiten by Karl Reimer Godt
# Applies the usual "Puppy License"
Version='1.0 Puppy-Linux-Racy_5.3 KRG'

bckl_dir=`echo -e /sys/class/backlight/*/`
curr_file=/sys/class/backlight/*/actual_brightness
set_file=/sys/class/backlight/*/brightness
max_file=/sys/class/backlight/*/max_brightness
uevent_file=/sys/class/backlight/*/uevent

usage(){
MSG="
$0 [list|info|help|version] [ # [FILENAME]]

Script to set the display brightness for Laptops.
Defaultfilename : /sys/class/backlight/*/brightness

"
if [ "$2" ];then
MSG="$MSG

$2"
fi
echo "$MSG"
[ "$DISPLAY" ] && xmessage -bg blue3 "$MSG"
exit $1
}

case $1 in
help) usage 0;;
version) echo -e "\n$0: Version '$Version'\nTry help for more info\n"
exit 0;;
list) if find /sys -name "backlight" ;then :
else echo "No backlight support detected. Did the driver load?"
exit 1;fi
ls -1 /sys/class/backlight/*/
exit $?
;;
info)


echo "GENERAL INFO:"
ls -l $uevent_file |rev|sed 's- -\n-'|rev
CONT=`cat $uevent_file`
[ "$CONT" ] || CONT='No entry.'
echo "$CONT"
echo

echo "CURRENT:"
ls -l $curr_file |rev|sed 's- -\n-'|rev
CONT=`cat $curr_file`
[ "$CONT" ] || CONT='No entry.'
echo "CUR_SET='$CONT'"

echo

echo "SET AS:"
ls -l $set_file |rev|sed 's- -\n-'|rev
CONT=`cat $set_file`
[ "$CONT" ] || CONT='No entry.'
echo "_SET='$CONT'"

echo

echo "MAXIMUM to be SET TO:"
ls -l $max_file |rev|sed 's- -\n-'|rev
CONT=`cat $max_file`
[ "$CONT" ] || CONT='No entry.'
echo "MAX_SET='$CONT'"

;;

[0-9]*)
VAL=$1

if [ "$2" ];then
[ -e "$2" ] || usage 1 "'$2' does not exist."
[ -d "$2" ] && usage 1 "Is a directory."
[ -f "$2" ] || usage 1 "Not a regular file."
echo $VAL > "$2"
exit $?;fi

if find $bckl_dir -name "brightness";then
echo $VAL > $bckl_dir/brightness
else
usage 1 "Not Found."
fi
exit $?
;;
"") usage 1 "Need Parameter.";;
*) usage 1 "Unknown Parameter.";;
esac

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

Update :

Want first to say that the kernel acpi driver named video.ko apparently is responsible for creating sysfs files .
I detected it while running with the video.ko driver blacklisted .

Code: Select all

/sbin/modprobe -v --first-time video brightness_switch_enabled=1
issues
insmod /lib/modules/2.6.30.9-KRG-i486-compiled-AcerLaptop-rev1/kernel/drivers/acpi/video.ko brightness_switch_enabled=1
My script named as set_backlight

Code: Select all

set_backlight info
issues
GENERAL INFO:
/sys/class/backlight/acpi_video0/uevent
-rw-r--r-- 1 root root 4096 Aug 7 10:31
No entry.

CURRENT:
/sys/class/backlight/acpi_video0/actual_brightness
-r--r--r-- 1 root root 4096 Aug 7 10:31
CUR_SET='12'

SET AS:
/sys/class/backlight/acpi_video0/brightness
-rw-r--r-- 1 root root 4096 Aug 7 10:31
_SET='0'

MAXIMUM to be SET TO:
/sys/class/backlight/acpi_video0/max_brightness
-r--r--r-- 1 root root 4096 Aug 7 10:31
MAX_SET='15'

Code: Select all

set_backlight 10
works for me currently running kernel 2.6.30.9 on Asus EeePC 1005HAG (also the Fn F5/F6 keys to step down/up the backlight) .

Reference to Thread that woke me up >
Laptop Brightness Issues- Toshiba T115d/Precise 5.7 (Solved)
http://murga-linux.com/puppy/viewtopic.php?t=87819

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#3 Post by Karl Godt »


User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#4 Post by greengeek »

Hi Karl, I am trying to use your script set_bl above but it returns an error as follows:

Code: Select all

# set_bl 2
/sys/class/backlight/acpi_video0/brightness
/sys/class/backlight/toshiba/brightness
/usr/bin/set_bl: line 85: /sys/class/backlight/acpi_video0/ /sys/class/backlight/toshiba//brightness: No such file or directory
# 
I am using a Toshiba laptop which does not seem to respond to some other common methods for backlight adjustment. It does respond to xrandr commands and the xgamma adjustments but I would like to get your script working if possible.

I do seem to have the correct directories available, so I don't know what is generating the error message. Is it normal that two forward slashes "//" are showing in the final line of the error message?

EDIT : The following commands do help me to adjust my backlight :
echo 0 > /sys/class/backlight/acpi_video0/brightness
echo 1 > /sys/class/backlight/acpi_video0/brightness
echo 2 > /sys/class/backlight/acpi_video0/brightness

No other values work on this PC so it seems that "2" is the max permissible number for my video card (early nvidia running nouveau driver at present)

EDIT 2 : I am using a Slacko 5.6 derivative

EDIT 3 : Sorry, should have posted the output of set_bl info:

Code: Select all

# set_bl info
GENERAL INFO:
/sys/class/backlight/acpi_video0/uevent
-rw-r--r-- 1 root root 4096 Oct 13 06:28
/sys/class/backlight/toshiba/uevent
-rw-r--r-- 1 root root 4096 Oct 13 06:29
No entry.

CURRENT:
/sys/class/backlight/acpi_video0/actual_brightness
-r--r--r-- 1 root root 4096 Oct 13 06:28
/sys/class/backlight/toshiba/actual_brightness
-r--r--r-- 1 root root 4096 Oct 13 06:29
CUR_SET='2
7'

SET AS:
/sys/class/backlight/acpi_video0/brightness
-rw-r--r-- 1 root root 4096 Oct 13 06:54
/sys/class/backlight/toshiba/brightness
-rw-r--r-- 1 root root 4096 Oct 13 06:17
_SET='2
7'

MAXIMUM to be SET TO:
/sys/class/backlight/acpi_video0/max_brightness
-r--r--r-- 1 root root 4096 Oct 13 06:28
/sys/class/backlight/toshiba/max_brightness
-r--r--r-- 1 root root 4096 Oct 13 06:29
MAX_SET='2
7'
# 
.
Attachments
Tosh_backlight.jpg
(35.13 KiB) Downloaded 861 times

Post Reply