Bug 295982

Summary: Brightness change should not be detected using hotkeys
Product: [Frameworks and Libraries] solid Reporter: Corentin Chary <corentin.chary>
Component: powermanagementAssignee: Dario Freddi <drf>
Status: RESOLVED FIXED    
Severity: normal CC: acelan, afiestas, alexandrep.piel, bwat47, cfeck, dct, fadnix, fheday, flo, kde, kitts.mailinglists, kribby, matej, mihais23, rauchwolke, rockonthemoonfm, rthomsen6, valdikss
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 4.11.0

Description Corentin Chary 2012-03-14 08:31:17 UTC
#182400 added a visual notifications when hotkeys are detected.

Unfortunately, this is not the right way to detect brightness change, because brightness can change without hotkeys "notifications". This happens for example when using asus-wmi on newer eeepc and asus laptops.

What you should do is either:
- monitoring /sys/class/backlight/<yourbacklight>/actual_brightness (using inotify, or similar)
- or monitoring uevents

Example of uevent comming from asus-wmi:

KERNEL[1331713472.121557] change   /devices/platform/asus-nb-wmi/backlight/asus-nb-wmi (backlight)                                                                                                                 
UDEV_LOG=3                                                                                                                                                                                                         
ACTION=change                                                                                                                                                                                                      
DEVPATH=/devices/platform/asus-nb-wmi/backlight/asus-nb-wmi                                                                                                                                                        
SUBSYSTEM=backlight                                                                                                                                                                                                
SOURCE=hotkey                                                                                                                                                                                                      
SEQNUM=1888

KERNEL[1331713472.680570] change   /devices/platform/asus-nb-wmi/backlight/asus-nb-wmi (backlight)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/platform/asus-nb-wmi/backlight/asus-nb-wmi
SUBSYSTEM=backlight
SOURCE=hotkey
SEQNUM=1889

The "SOURCE" property can be "hotkey" or "sysfs" but I think a notification should be shown is both cases.
Comment 1 Dario Freddi 2012-03-14 08:36:02 UTC
Thanks for reporting. You are partly right, since brightness keys are not handled for merely notifying the user of a brightness change but for changing the actual brightness instead. So it's more an action than a notification. What is missing is a way to monitor brightness changes when they happen outside of the power management framework realm, like in your case. Probably monitoring uevents is less expensive than watching for file changes, I'll give it a shot in the next days
Comment 2 FabioLima 2012-03-14 15:48:06 UTC
Another point worth noting is that KOSD seems to work fine on eeepc
Comment 3 Corentin Chary 2012-03-14 16:11:49 UTC
There are different kind of eeepc, some are using eeepc-laptop, others are using asus-wmi + eeepc-wmi, and I'm not sure they all have the same hotkey/brightness behavior.
Comment 4 Ragnar Thomsen 2012-12-04 18:42:15 UTC
I can confirm this. Pressing the brightness hotkeys on my Asus laptop does not elicit any events in KDE, although the screen brightness does get adjusted. This results in an actual brightness level different from the one stated by solid/KDE.
Comment 5 Ragnar Thomsen 2012-12-27 12:15:28 UTC
*** This bug has been confirmed by popular vote. ***
Comment 6 Matěj Laitl 2013-01-02 16:58:42 UTC
Dario, you've asked me to test a patch in bug 265357 comment 48. Sorry for nearly year delay, but please provide the patch, I'm happy to test and experienced with KDE and Qt development.
Comment 7 Alex Fiestas 2013-04-02 19:01:19 UTC
The thing is, we don't always want to show the OSD, for example we do not want to show the OSD when you are moding the brightness in the battery plasmoid (you already know how much brightness are you putting).

If we show the OSD when the brightness changes (does not matter from where we get the event) we can't do that since we can't know if we should show the OSD or not.

Not an easy thing to solve :/
Comment 8 Corentin Chary 2013-04-03 05:55:02 UTC
I guess the obvious solution would be to allow plasmoid (and possibly others) to temporary disable the OSD ?
Comment 9 Alex Fiestas 2013-04-03 09:05:32 UTC
Not that easy, since each "key up" or "key down" will have different results in the system, will be difficult to know when the "key up" or the "plasmoid brightness modification" has been done.
Comment 10 Dario Freddi 2013-04-20 18:32:13 UTC
Git commit 245493d67eed84f56b62bceae56aa83c58891f64 by Dario Freddi.
Committed on 20/04/2013 at 20:12.
Pushed by dafre into branch 'master'.

Merge branch 'brightness-changed-signals'

Now brightness changes are always detected and streamed when hardware changes.
The cache itself is hardware based.
Related: bug 313918

M  +46   -10   powerdevil/daemon/backends/upower/powerdevilupowerbackend.cpp

http://commits.kde.org/kde-workspace/245493d67eed84f56b62bceae56aa83c58891f64
Comment 11 dct 2013-05-16 12:08:27 UTC
Any chance the fix goes to 4.10 as well?
Comment 12 Alex Fiestas 2013-05-16 12:45:45 UTC
The fix is too big to be backported to 4.10 :/
Comment 13 Brandon Watkins 2013-09-23 03:34:28 UTC
I'm still seeing this problem. system76 lemur ultra. using brightness fn keys does change brightness but I get no OSD and KDE does not realize the brightness has changed. It works flawlessly in gnome, unity, XFCE... I have tried both kde 4.10, 4.11, and 4.11.1, same behavior in all.
Comment 14 Jim Jones 2013-09-27 15:17:24 UTC
same here on kde 4.11.1 with lenovo x220 and x230
Comment 15 Jim Jones 2013-09-27 15:18:05 UTC
same here means, the bug isn't fixed
Comment 16 Christoph Feck 2013-10-12 17:30:26 UTC
Reopening based on recent comments.
Comment 17 Fahad Alduraibi 2013-11-12 01:51:46 UTC
Same here, using the keyboard hotkeys will change the brightness but no OSD.

On the other hand, changing the brightness from the "Battery Monitor" in the system tray is really annoying since when sliding the brightness control for every 10% change the OSD will come up and that will cause the Battery Monitor control dialog to disappear! (like if it lost focus) so I have to click on the battery icon again to continue adjusting the brightness. Same thing also happens when adjusting the brightness of the backlit keyboard from the battery monitor control dialog, however, when adjusting the keyboard brightness from hotkeys it works great and I do see the OSD too.

Fedora 19 x86_64
KDE 4.11.2
ASUS N550JV laptop (using module "asus_nb_wmi" and kernel parameter "acpi_osi= ")
Comment 18 rockonthemoonfm 2013-11-12 22:15:23 UTC
on a ASUS X54C, i fix this by adding the flag acpi_osi= to Arch kernel line, and everything works fine :)
Comment 19 Kishore 2014-02-08 06:07:03 UTC
I still have the problem on my thinkpad x220 with KDE 4.12.1

Using Fn keys changes brightness but no OSD.
Comment 20 AceLan Kao 2014-02-10 06:03:39 UTC
Hi,
For those who has no OSD while pressing the hotkey, I'm wondering is there a keyevent when hotkey pressed.
You can monitor the hotkey event by
   sudo showkey
Comment 21 valdikss 2014-02-10 06:05:51 UTC
Yes, there is. Keycode 224 and 225.
Comment 22 Kishore 2014-02-10 06:32:56 UTC
Same here. 224 and 225
Comment 23 Ryan 2014-03-03 19:21:57 UTC
Same for me, too. 224 and 225
Comment 24 Mihai 2014-11-20 21:23:59 UTC
Same issues on an Asus N550JK. Same keycodes.
Comment 25 Kishore 2014-11-21 05:41:31 UTC
Im now trying plasma 5 and here is works as expected.
Comment 26 Kai Uwe Broulik 2015-01-25 22:08:00 UTC
Plasma 5 only ever shows the OSD when the user manually changes the brightness but never when the system automatically does.
Comment 27 Matěj Laitl 2015-01-26 18:49:50 UTC
(In reply to Kai Uwe Broulik from comment #26)
> Plasma 5 only ever shows the OSD when the user manually changes the
> brightness but never when the system automatically does.

Shouldn't it do the exact opposite?
Comment 28 Kai Uwe Broulik 2015-01-26 18:50:39 UTC
No, when you change the brightness you want a feedback. When the system is changing it automatically you don't want to get annoyed by popups all the time.