Solved Backlight set to zero after X server starts

Hello friends of BSD,

recently, I've been struggling with backlight after X server starts on ASUS laptop. Everything is normally seen in TTY, but after executed startx or automatic slim login manager enabled boot in Xserver dims backlight to zero. For this purpose, I've installed graphics/intel-backlight package and after each boot, without seeing what's on the screen, I go to TTY0, login as root, and execute command intel_backlight 100.

Can you, please, point me to a file or script where this command can be put so it will execute automatically after X server stars?

Thank you so much.
 
  • Thanks
Reactions: mro
Create /etc/rc.local and make sure you use absolute paths:
Code:
/usr/local/bin/intel_backlight 100
EDIT: Scratch that. That's not going to work. /etc/rc.local is sourced before slim starts.
 
Hi rotech911 and welcome to the forums. I looked at the man page for the Xorg intel driver to see whether you could put something in a configuration file rather than running a command. Unfortunately configuring the brightness appears to require running xrandr, which is no improvement on your intel_backlight command:
You can use the xrandr tool to control outputs on the command line as follows:
xrandr −−output output −−set property value
[...]
LVDS
Low Voltage Differential Signalling output (typically a laptop LCD panel). Available properties:

BACKLIGHT - current backlight level (adjustable)
By adjusting the BACKLIGHT property, the brightness on the LVDS output
can be adjusted. In some cases, this property may be unavailable (for
example if your platform uses an external microcontroller to control
the backlight).

As far as I can tell from the documentation for the (now abandoned I believe) x11/slim, it is not possible to run a command before SLiM starts. If you really want to use SLiM, you could implement an ugly hack to run your command with a single keypress. In the configuration file I see an option for screenshot_cmd:
Code:
# Executed when pressing F11 (requires imagemagick)
screenshot_cmd  import -window root /slim.png
Instead of taking a screenshot, you could configure this to run your intel_backlight command. So, you would start up to a black screen, press F11 and then be able to see what you are typing.

Instead of SLiM, I use x11/xdm, which is more complex to configure than SLiM, but also more flexible. It allows you to run whatever you like, including a command to set the screen brightness. In fact, I use a simple script to set the brightness appropriately for the time of day on my laptop on startup. You could switch to XDM and do something similar.
 
I had another thought if you want to use SLiM. If you are starting SLiM by adding slim_enable="YES" to /etc/rc.conf, you could write your own startup script (refer to this guide) with a dependency on the SLiM script to run your brightness command. This is a version of what tobik was suggesting, but ensuring that things run in the correct order.

If you are starting SLiM by editing /etc/ttys, I had considered whether it would be possible to call a script from ttys(5) rather than directly calling the SLiM executable. Such a script could run SLiM then run the brightness command. However, I don't think this will work as I'm pretty sure that SLiM would need to be running in the foreground rather than as a daemon and therefore the brightness command wouldn't be executed when you need it.
 
Edit slim.conf to contain
Code:
default_xserver  /home/me/bin/X
Create /home/me/bin/X (remember to chmod 755 /home/me/bin/X)
Code:
#!/bin/sh

(sleep 5; intel_backlight 100) &
exec /usr/local/bin/Xorg "$@"

Untested etc,
Juha

My screen reverts to full brightness after screen saver is reset, maybe yours will revert to black ?
 
Dear all,

thank you for your suggestions! Since I didn't succeed to solve my problem with individual suggested solution, I tried with the combination and - voilà! Finally!
This worked for me, in case anyone else will need it:
I created new file /etc/rc.local with the following content:

Code:
(sleep 4; intel_backlight 100) &
(sleep 6; intel_backlight 100) &
(sleep 8; intel_backlight 100) &
Even though this script is executed before slim, it does the job perfectly!

Maybe I will upgrade it to a script, which will monitor slim process and will execute backlight command only once, when I'll have time.

Until then ... live long and code proper! :)
 
Last edited by a moderator:
Back
Top