rickysarraf / laptop-mode-tools

Power Savings tool for Linux
https://www.researchut.com/tags/laptop-mode-tools/
GNU General Public License v2.0
550 stars 47 forks source link

LCD brightness changes on USB insertion #182

Closed LRitzdorf closed 2 years ago

LRitzdorf commented 2 years ago

Describe the bug When a USB device is plugged in, the LCD display brightness is reset to the level specified in /etc/laptop-mode/conf.d/lcd-brightness.conf.

This occurs with a Logitech Unifying dongle, flash drives, and unusual devices like a Digilent Analog Discovery (a USB-based oscilloscope multitool) and an Intel/Altera DE10-Lite FPGA development board. Thus, it seems to be triggered by all USB devices.

In #94, you note that "LMT is invoked whenever there is a power state change. It also is invoked during swsusp resume and on USB device additions" (emphasis mine). Is this expected behavior, then? If so, is there a way to prevent my brightness from being reset every time I connect a USB device? During everyday use, having my brightness reset whenever I plug something in is a bit inconvenient, as well as unintuitive.

To Reproduce Steps to reproduce the behavior:

  1. Edit lcd-brightness.conf to specify your preferred backlight levels for each power state
  2. Change your brightness manually to a different level
  3. Plug in a USB device
  4. Observe that brightness is reset to the level specified in the config file

Expected behavior From an everyday use perspective, I would not expect connecting a USB device to trigger a brightness change, though it seems this might be intended behavior (see above).

Important Information:

rickysarraf commented 2 years ago

Yes. This is the expected behavior. But you can customize it, if you don't like it.

$ cat /lib/udev/rules.d/99-laptop-mode.rules 
ACTION=="change", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_NAME}=="|AC|ACAD|ADP*", RUN+="lmt-udev auto"
ACTION=="add|remove", SUBSYSTEM=="machinecheck", RUN+="lmt-udev auto"
ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force"

# Run a particular module only
#ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force modules=runtime-pm devices=%k"

You could change lmt-udev force to auto. But it may have some other side-effects like the newly plugged usb device may not inherit the power savings settings that you may have specified in laptop-mode-tools configs.

On the other hand, you could also enable the module only configuration:

ACTION=="add", SUBSYSTEM=="usb", RUN+="lmt-udev force modules=runtime-pm devices=%k"

Please do share your results. 🙏🏽

rickysarraf commented 2 years ago

Yes. That was the reason to call force. see commit id: f4d6b93e33bb7a1fd030f073fb1bb48c0e60f4ba

LRitzdorf commented 2 years ago

Perfect, that seems to work as expected! I suppose there's a reason that line is provided in the udev rules file :grin: (and I should probably have checked that before opening an issue here). Thanks for the quick response, and have a nice day!