feat: Add keyboard back-light quick setting with slider - #883
Conversation
|
I like the feature, even if for some reason my HP is still not supported (not the issue of this here). In my opinion, we can use the same sliders as for the other components.
https://github.com/user-attachments/assets/abbe39c5-1fae-4333-aa6b-6810743300c5 But a button that opens the slider is nothing I would like to have. |
|
Hi, thanks for the support! From my point of view, we should place a config setting to enable this option (by default, I prefer to hide this functionality. Then we should probably change the UX. A quick settings with a simple slider seems too much. Maybe we should simply place the slider under the screen brightness. |
|
yes I agree, just add it under the brightness slider. |
|
@MalpenZibo thanks for the feedback! Quick SettingThe main reason for placing the slider inside a quick-setting was to copy gnome and macOS quick settings.
Config FlagAs for the configuration flag - the slider would be already hidden for any system without built-in keyboard backlight - this includes USB keboards since they normally handle backlight using keyboard shortcuts. |
|
@romanstingler |
romanstingler
left a comment
There was a problem hiding this comment.
I had a look,
first I added the icons to the font just replace these files with yours in assets/
ashell_custom_icon_project.zip
-
keyboard_backlight_slideris undocumented in the docs -
scroll step logic is duplicated verbatim from(NO NEED TO de-duplicate now, there will be a cleanup session later over more code)brightness.rs, same 5% calculation and clamp
The biggest thing is that each slider tick spawns a fresh tokio task that builds a new proxy and calls set_brightness. Those tasks run concurrently and their completion order depends on the scheduler. If task N-1 lands after task N, the backlight settles one step off from where you dropped the slider, and UPower reports that value back so the UI shows the wrong-but-real state with no correction. The brightness service solves this with a commander channel and a throttle that coalesces writes and keeps them ordered.
| UPowerCommand::SetKbdBacklight(brightness) => { | ||
| let _ = self.commander.send(brightness); | ||
| iced::Task::none() | ||
| } |
There was a problem hiding this comment.
This is the only new code in the function.
rest is just indentation change and splitting into separate match arms due to fact that Task::none() can now be returned.
IconsThanks for the icons @romanstingler! My svgs where way too small though - not even visible.
I hope this is the propper way. Commmander
I think this is only partially true - we have the That being said - while it "works on my machine" due to backlight changes being near instantaneous - it would indeed be more robust to have a proper throttled rx/tx queue. The commander has been added to the upower service (slider only). :) |
Add a Keyboard Backlight section to the settings module page covering `keyboard_backlight_slider`, the UPower requirement, the icon toggle and the 5% scroll step, plus the option in the full config example and the developer config reference.
| .collect(); | ||
|
|
||
| let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); | ||
| Self::start_commander(conn.clone(), rx); |
There was a problem hiding this comment.
Maybe we should start the commander only if we can actually send a command to the device and the feature is enabled in the config
| pub power_profile: PowerProfile, | ||
| pub kbd_backlight: Option<KbdBacklight>, | ||
| conn: zbus::Connection, | ||
| commander: UnboundedSender<u32>, |
There was a problem hiding this comment.
It's strange to see an Option that is only present if the device supports the feature and a commander that is always present to send a command to change the KdbBacklight. Probably we should place both stuff in the same Option
There was a problem hiding this comment.
My bad - also patched.
By the way I have gone on a small side-quest - looking at implementing a custom widget,
which would also remove the need for commanders.
More info: #931 (comment)



output.mp4
n nerd-fonts so I drew the missing icons and added them to
AshellCustomIcon-Regular.otf*I used fontforge to edit the font. You can see that after the edit - the size has decreased. Not sure why, but I did test that mouse and keyboard status bar icons still look as expected.