Skip to content

Inrtoduce BrightnessManager dbus interface - #2831

Draft
garaevdi wants to merge 3 commits into
elementary:mainfrom
garaevdi:backlight-dbus-interface
Draft

Inrtoduce BrightnessManager dbus interface#2831
garaevdi wants to merge 3 commits into
elementary:mainfrom
garaevdi:backlight-dbus-interface

Conversation

@garaevdi

@garaevdi garaevdi commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

With gnome 49 screen brightness management was moved into mutter. This is a simple and naive implementation of backlight interface which could be controlled via DBus.

Note: to build this you would need mutter 50.2

@leolost2605

Copy link
Copy Markdown
Member

Did you check whether it might already be exposed via org.gnome.mutter.displayconfig ?

@garaevdi

Copy link
Copy Markdown
Contributor Author

Did you check whether it might already be exposed via org.gnome.mutter.displayconfig ?

Yes, but I think it's better to abstract it with a gala interface. Otherwise both switchboard-plug-power and wingpanel-power would need to implement the same things (handling monitors changes, converting raw brightness values to percentages).

Also you won't have to deal with complicated dbus types

@danirabbit danirabbit added this to OS 9 Apr 30, 2026
@danirabbit danirabbit moved this to Needs Review in OS 9 Apr 30, 2026
@danirabbit
danirabbit requested a review from leolost2605 April 30, 2026 17:42

@leolost2605 leolost2605 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I think it's better to abstract it with a gala interface. Otherwise both switchboard-plug-power and wingpanel-power would need to implement the same things (handling monitors changes, converting raw brightness values to percentages).

Hmm yeah that makes sense. Also I just saw there are vague plans to drop the backlight from the dbus api anyways 😅
Though I think we should use having to implement this to already prepare for individual multi monitor backlight control which AFAIR is the reason why gnome moved the brightness control into mutter.

Also ig we have to implement save and restore too since it was dropped from mutter (though that only made 51 so ig we can follow up):
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4814
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4006

Comment thread src/BrightnessManager.vala Outdated
Comment thread src/BrightnessManager.vala Outdated
Comment thread src/Misc/BrightnessManager.vala
Comment thread src/meson.build Outdated
Comment thread vapi/Meta-18.metadata
@garaevdi
garaevdi force-pushed the backlight-dbus-interface branch from e2ce49c to 0d6805b Compare July 26, 2026 13:35
@garaevdi

Copy link
Copy Markdown
Contributor Author

@leolost2605 Rebased onto main and added keyboard shortcuts.
Not sure why this builds on development-target tho... IIRC mutter was missing includes in its' public headers. A fix is already there, but it is only available since 50.2, while resolute ships 50.1

@leolost2605

Copy link
Copy Markdown
Member

Though I think we should use having to implement this to already prepare for individual multi monitor backlight control which AFAIR is the reason why gnome moved the brightness control into mutter.

Any thoughts on this? I'd like to do it now because it requires a different public API.

@garaevdi

garaevdi commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Though I think we should use having to implement this to already prepare for individual multi monitor backlight control which AFAIR is the reason why gnome moved the brightness control into mutter.

Any thoughts on this? I'd like to do it now because it requires a different public API.

Not really, IMO some kind of manager object is still needed to provide a way to control "global" brightness scale or perhaps lock other monitors' scales to a global one. The last commit does something like this, but it's super WIP.

(And also it wouldn't compile due to another missing include in mutters' headers 🫠️)

@garaevdi
garaevdi force-pushed the backlight-dbus-interface branch from 450e6ff to ec074c8 Compare July 30, 2026 16:27
@garaevdi
garaevdi force-pushed the backlight-dbus-interface branch from ec074c8 to c6b1c4d Compare July 30, 2026 16:30
@leolost2605

Copy link
Copy Markdown
Member

"global" brightness scale

Yeah I was wondering if we even need that? I mean what would be the "global" scale if you have two monitors which both support brightness adjustment?

I had a quick look through your new commit and I think I wouldn't do individual dbus objects for individual monitors. The interface isn't expected to grow much bigger and having a single interface and addressing via an index is much simpler for the user of the interface IMO.

Maybe something like this:

// Core part
signal void monitors_changed ();
signal void monitor_brightness_changed (uint index);

void set_monitor_brightness (uint index, int brightness);
int get_monitor_brightness (uint index);
string get_monitor_name (uint index);
int get_n_monitors ();

// Some utilities
// For keybinds?
set_primary_monitor_brightness (int brightness);

// Idk do we want that?
set_all_monitor_brightness ();
  • The index doesn't actual mean anything and it is only guaranteed to address the same monitor until the next monitors_changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

3 participants