digitaltrails / vdu_controls

VDU controls - a control panel for monitor brightness/contrast/...
GNU General Public License v3.0
103 stars 4 forks source link

Create laptop backlight control by wrapping ddcutil #44

Open digitaltrails opened 1 year ago

digitaltrails commented 1 year ago

Support some laptop backlight adjustment by wrapping ddcutil with a wrapper that accepts DDC/CI commands on behalf of the laptop and translates them into whatever really needs to be done. It must implement:

That all appears pretty easy, except I don't own a laptop. If anyone with a laptop would like to explore this, I'd be happy to try and create ddcutil wrapper script according for them to experiment with.

denilsonsa commented 1 year ago

Once upon a time I had my own script to change the brightness: https://github.com/denilsonsa/small_scripts/blob/master/obsolete/change_LCD_brightness.py I have no idea if it is still relevant or if it still works.

I'm now sharing some extra information that may help you:

$ ls -lR /sys/class/backlight
/sys/class/backlight:
total 0
lrwxrwxrwx 1 root root 0 Jun 21 14:08 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

$ ls -lR /sys/class/backlight/intel_backlight/
/sys/class/backlight/intel_backlight/:
total 0
-r--r--r-- 1 root root 4096 Jul  8 12:51 actual_brightness
-rw-r--r-- 1 root root 4096 Jul  8 12:51 bl_power
-rw-r--r-- 1 root root 4096 Jul  8 12:49 brightness
lrwxrwxrwx 1 root root    0 Jun 21 14:08 device -> ../../card0-eDP-1
-r--r--r-- 1 root root 4096 Jun 21 14:08 max_brightness
drwxr-xr-x 2 root root    0 Jul  8 12:51 power
-r--r--r-- 1 root root 4096 Jul  8 12:51 scale
lrwxrwxrwx 1 root root    0 Jun 21 14:08 subsystem -> ../../../../../../../class/backlight
-r--r--r-- 1 root root 4096 Jun 21 14:08 type
-rw-r--r-- 1 root root 4096 Jun 21 14:08 uevent

/sys/class/backlight/intel_backlight/power:
total 0
-rw-r--r-- 1 root root 4096 Jul  8 12:52 autosuspend_delay_ms
-rw-r--r-- 1 root root 4096 Jul  8 12:52 control
-r--r--r-- 1 root root 4096 Jul  8 12:52 runtime_active_time
-r--r--r-- 1 root root 4096 Jul  8 12:52 runtime_status
-r--r--r-- 1 root root 4096 Jul  8 12:52 runtime_suspended_time

$ cd /sys/class/backlight/intel_backlight/

$ grep '' * */*
actual_brightness:30001
bl_power:0
brightness:30001
grep: device: Is a directory
max_brightness:120000
grep: power: Is a directory
scale:unknown
grep: subsystem: Is a directory
type:raw
grep: device/device: Is a directory
device/dpms:On
grep: device/drm_dp_aux0: Is a directory
grep: device/edid: binary file matches
device/enabled:enabled
grep: device/firmware_node: Is a directory
grep: device/i2c-9: Is a directory
grep: device/intel_backlight: Is a directory
device/modes:1920x1080
device/modes:1920x1080
grep: device/power: Is a directory
device/status:connected
grep: device/subsystem: Is a directory
device/uevent:DEVTYPE=drm_connector
device/waiting_for_supplier:0
grep: power/autosuspend_delay_ms: Input/output error
power/control:auto
power/runtime_active_time:0
power/runtime_status:unsupported
power/runtime_suspended_time:0
grep: subsystem/intel_backlight: Is a directory

You may want to look at how LXQt, XFCE, OpenBox or any of those handle the XF86MonBrightnessDown/XF86MonBrightnessUp keys.

Some laptops also have a keyboard backlight. I know KDE shows a slider for the display brightness and for the keyboard backlight under the "Battery and Brightness" systray icon.

Good luck! I'm not sure how long I'll still have this laptop, so my contributions to this issue moving forward will be limited.

digitaltrails commented 12 months ago

Thanks for the extra info. Reading your script and other info (such as the arch wiki), it does look like providing some limited laptop capability is a temptingly close possibility.

I struggle with the thought of buying a laptop I don't need. It does seem different brands of laptop might work a bit differently - so I might need to get access to more than one brand.

I do have a 20 year old Toshiba laptop gathering dust in a closet. I doubt it's very representative of modern hardware, but perhaps I could get a 32 bit linux to run on it and start from there. I'm in no hurry though, it's not anything I have a need for.

denilsonsa commented 12 months ago

I struggle with the thought of buying a laptop I don't need.

Then don't. ;) Don't buy if you don't need. Ask friends or relatives if they can help. Maybe a local repair shop might be able to help you, or may even be able to lend or rent a laptop for a few days. (I mean, it's an exceptional request, but it's worth asking. They may even like the idea of the project and thus more willing to contribute.)

digitaltrails commented 4 months ago

This idea could be implemented in ddcutil-service rather than in vdu_controls. Something to consider.