Page MenuHomeFreeBSD

rc: add a backlight service to save/restore backlight levels
ClosedPublic

Authored by kevans on Tue, Sep 1, 3:41 AM.
Tags
None
Referenced Files
F170872122: D59296.diff
Mon, Sep 7, 4:40 AM
F170855165: D59296.diff
Mon, Sep 7, 1:50 AM
F170852362: D59296.id185531.diff
Mon, Sep 7, 1:24 AM
F170840361: D59296.id185531.diff
Sun, Sep 6, 11:29 PM
Unknown Object (File)
Sun, Sep 6, 4:10 AM
Unknown Object (File)
Sat, Sep 5, 6:04 PM
Unknown Object (File)
Sat, Sep 5, 1:50 PM
Unknown Object (File)
Sat, Sep 5, 12:24 PM

Details

Summary

The default on my laptop is annoyingly bright, and this is a useful feature to
mitigate that. The backlight script is largely a copy of the mixer
service which provides the same value for mixers, but this one is
specifically dependant on kld to allow DRM drivers a chance to attach.

Relnotes: maybe

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 76374
Build 73257: arc lint + arc unit

Event Timeline

kevans requested review of this revision.Tue, Sep 1, 3:41 AM
libexec/rc/rc.d/backlight
4

this is weird, I bet this comes from copy/paste from rc.d/mixer, but you can probably right your own here (and use SPDX)

31

You probably want required kld not provide kld

arrowd added inline comments.
libexec/rc/rc.conf
45

Enabling this by default will clash with DEs doing their own backlight management.
But unless user call save manually, I think it should really get in the way.

libexec/rc/rc.d/backlight
73

I'd prefer /var/db/backlight/... or /var/db/backlight-${1}-state

libexec/rc/rc.conf
45

I'm cool with off-by-default, I'll just want to amend backlight(8) to mention that the cpability exists for th rest of us.

libexec/rc/rc.d/backlight
31

*sigh* EDOOFUS at the last minute

73

The naming here forces them to be /var/db/backlightN-state because I wanted to explicitly ignore aliases up in list_backlights. That said, I have no objection to /var/db/backlight and I've somewhat wished that mixer did the same.

kevans marked 4 inline comments as done.

Review feedback:

  • Scope the backlight settings off into /var/db/backlight
  • Turn it off by default, mention it in the manpage
  • Condense the license/copyright header down and fix the PROVIDE/REQUIRE
  • Use my preferred quoting style while we're here

Thanks, my annoying 30% default backlight level will soon be history.

This revision is now accepted and ready to land.Tue, Sep 1, 1:49 PM

looks fine from the pkgbase side.

Can you put this in rc.conf.5 too?

Can you put this in rc.conf.5 too?

How about:

diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5
index 586e33980fd8..4db1586f2fcc 100644
--- a/share/man/man5/rc.conf.5
+++ b/share/man/man5/rc.conf.5
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 30, 2026
+.Dd September 1, 2026
 .Dt RC.CONF 5
 .Os
 .Sh NAME
@@ -4433,6 +4433,11 @@ For example:
 autobridge_interfaces="bridge0"
 autobridge_bridge0="tap* dc0 vlan[345]"
 .Ed
+.It Va backlight_enable
+.Pq Vt bool
+If set to
+.Dq Li YES ,
+enable saving and restoring backlight levels at shutdown and boot time.
 .It Va mixer_enable
 .Pq Vt bool
 If set to

That looks perfect to me!