Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
laptop brightness is max after reboot [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Efo
Guru
Guru


Joined: 23 Jun 2005
Posts: 494

PostPosted: Sun Apr 02, 2017 4:32 pm    Post subject: laptop brightness is max after reboot [SOLVED] Reply with quote

Hi all,

I cant figure out how to set a default value for the backlight of my laptop. The controls work, but every time I reboot the light is set to max.

gentoo wiki mentions
Code:
/etc/laptop-mode/conf.d/lcd-brightness.conf
(which I think is where the default values are stored), but I dont have that file.

I guess what I am looking for is where to generate the conf file and then I will follow this syntax, but since I dont have the file that may be obsolete.

Any help is (as always) highly appreciated.

Thanks,

Efo


Last edited by Efo on Mon Apr 03, 2017 12:55 am; edited 1 time in total
Back to top
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Sun Apr 02, 2017 6:13 pm    Post subject: Reply with quote

I don't use the "laptop-mode-tools", which might include the "missing config file" that you ask about.

If you have installed laptop-mode-tools, and the config file still isn't there, you would just create it.

The method I use to set LCD brightness at boot is a one line command in /etc/local.d/local.start

That file is not part of any package, but is suggested by openrc. More particularly, it is suggested by a message in /etc/init.d/local. If you don't use openrc to start your system (that is, if you use systemd), then this one liner in /etc/local.d/local.start would have NO effect.

I made /etc/local.d/local.start with a text editor. After I created the file, I made sure /etc/init.d/local was part of my openrc startup sequence, by issuing the command `rc-update add local default`

Code:
# /etc/local.d/local.start:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/local.start,v 1.4 2002/11/18 19:39:22

# This is a good place to load any misc.
# programs on startup ( 1>&2 )

# Adjust backlight brightness
echo 8 > /sys/class/backlight/acpi_video0/brightness


Your computer and setup may use a different "/sys" file for this function, but I see reference to this location in the config file that you reviewed.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Apr 03, 2017 12:48 am    Post subject: Reply with quote

Efo ... as cboldt mentions, its somewhat dependent on what your backlight provides, but here is a script that (absent of any parameter) will set the brightness to half that of max_brightness (you could of course set the default to whatever value you want).

Code:
#!/bin/sh
set -e

backlight_sys_dir="/sys/class/backlight/intel_backlight"

read -r max_brightness < "${backlight_sys_dir}/max_brightness"
read -r curr_brightness < "${backlight_sys_dir}/brightness"

if [ "$#" -eq 0 ] ; then
    # set to half that of 'max_brightness'
    echo $((max_brightness / 2)) > ${backlight_sys_dir}/brightness
    exit 0
fi

case "$1" in
      up) increment="+ 10" ;;
    down) increment="- 10" ;;
       *) exit 1 ;;
esac

new_brightness=$(($curr_brightness $increment))

if $((new_brightness < 1)) || $((new_brightness > $max_brightness)); then
    exit 1
else
    echo "$new_brightness" > ${backlight_sys_dir}/brightness
fi

This could similarly used in /etc/local.d ... and you can also then call the script and pass 'up' and 'down' to adjust the brightness by plus/minus 10 (I call it via acpid with those parameters taken from 'brightnessup' and 'brightnessdown' keys).

HTH & best ... khay
Back to top
View user's profile Send private message
Efo
Guru
Guru


Joined: 23 Jun 2005
Posts: 494

PostPosted: Mon Apr 03, 2017 12:54 am    Post subject: Reply with quote

Hi cboldt and khayyam,

Thank you for the reply.
For some reason I was expecting to have some config file already present; however, your suggestions make a lot of sense: just a little scripting will do.

Thank you for your help.

Cheers,

Efo
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum