Repository navigation
DeviceManager: use gala's brightness interface #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
leolost2605
merged 25 commits into
elementary:main
from
garaevdi:gala-brightness-interface
Nov 18, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
96d1856
DeviceManager: use gala's brightness interface
garaevdi 3d34157
Merge branch 'main' into gala-brightness-interface
zeebok 8a12a7c
Update for interface changes
garaevdi 29b4e17
Merge branch 'main' into gala-brightness-interface
garaevdi 3063d97
Adressing comments
garaevdi 0c4c43c
Tweak appearance a bit
garaevdi d92efc4
Merge branch 'main' into gala-brightness-interface
zeebok a59d72f
Colapse DBus interface class name
garaevdi 074a3c4
Use correct DBus interface name
garaevdi 3a175c2
Utils: store natural scroll settings internally
garaevdi c385abc
BrightnessManager: Simplify init
garaevdi ca51f57
ScreenBrightnessList: use ListBox's separator
garaevdi b6d92bb
BrightnessManager: Separate monitor detection into separate property
garaevdi 5ff0d1e
PopoverWidget: Properly hide extra separators
garaevdi 10e07ce
Indicator: Hide when there is no monitors
garaevdi cea46cc
ScreenBrighnessRow: Use `Granite.Box`
garaevdi 956c5d1
ScreenBrighnessRow: Avoid using lambdas
garaevdi fb47c4d
ScreenBrightnessRow: Use printf
garaevdi 7cbf495
Utils: Don't try to change monitor's brightness if there is no monitors
garaevdi d7c57bf
Use modern license headers
garaevdi 605af47
BrightnessManager: Simplify getters
garaevdi 884b4bd
ScreenBrightnessRow: Colapse Gtk/Granite namespaces
garaevdi 0f63778
PopoverWidget: Avoid using lambdas
garaevdi bfa6596
Utils: Actually get scroll settings
garaevdi 528d435
Merge branch 'main' into gala-brightness-interface
zeebok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| * Copyright 2026 elementary, Inc. (https://elementary.io) | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| * | ||
| * Authored by: Denis Garaev <garaevdi@outlook.com> | ||
| */ | ||
|
|
||
| public class Power.Services.BrightnessManager : Object { | ||
| private const string GALA_INTERFACE = "io.elementary.gala.BrightnessManager"; | ||
| private const string GALA_PATH = "/io/elementary/gala/BrightnessManager"; | ||
|
|
||
| public signal void monitors_changed (); | ||
| public signal void monitor_brightness_changed (int index, double value); | ||
|
|
||
| private Power.GalaBrightnessManager? gala_brightness_manager; | ||
|
|
||
| private static BrightnessManager? instance = null; | ||
|
|
||
| public bool present { | ||
| get { return gala_brightness_manager != null; } | ||
| } | ||
|
|
||
| public bool has_monitors { | ||
| get { | ||
| if (gala_brightness_manager == null) { | ||
| return false; | ||
| } | ||
|
|
||
| return get_n_monitors () > 0; | ||
| } | ||
| } | ||
|
|
||
| construct { | ||
| try { | ||
| gala_brightness_manager = Bus.get_proxy_sync (BusType.SESSION, GALA_INTERFACE, GALA_PATH); | ||
| gala_brightness_manager.monitors_changed.connect (on_monitors_changed); | ||
| gala_brightness_manager.monitor_brightness_changed.connect (on_monitor_brightness_changed); | ||
| } catch (Error e) { | ||
| warning ("Couldn't connect to Gala's BrightnessManager: %s", e.message); | ||
| } | ||
| } | ||
|
|
||
| public static Power.Services.BrightnessManager get_default () { | ||
| if (instance == null) { | ||
| instance = new BrightnessManager (); | ||
| } | ||
|
|
||
| return instance; | ||
| } | ||
|
|
||
| public int get_n_monitors () { | ||
| try { | ||
| return gala_brightness_manager.get_n_monitors (); | ||
| } catch (Error e) { | ||
| warning ("Couldn't get number of monitors: %s", e.message); | ||
| return -1; | ||
| } | ||
| } | ||
|
|
||
| public double get_global_brightness () { | ||
| try { | ||
| return gala_brightness_manager.get_global_brightness ().clamp (0.0001, 1.0); | ||
| } catch (Error e) { | ||
| warning ("Couldn't get global brightness: %s", e.message); | ||
| return -1.0f; | ||
| } | ||
| } | ||
|
|
||
| public void set_global_brightness (double value) { | ||
| try { | ||
| gala_brightness_manager.set_global_brightness (value.clamp (0.0001, 1.0)); | ||
| } catch (Error e) { | ||
| warning ("Coulnd't set global brightness: %s", e.message); | ||
| } | ||
| } | ||
|
|
||
| public string get_monitor_name (int index) { | ||
| try { | ||
| return gala_brightness_manager.get_monitor_name (index); | ||
| } catch (Error e) { | ||
| warning ("Couldn't get %n monitor's name: %s", index, e.message); | ||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| public double get_monitor_brightness (int index) { | ||
| try { | ||
| return gala_brightness_manager.get_monitor_brightness (index).clamp (0.0001, 1); | ||
| } catch (Error e) { | ||
| warning ("Couldn't get %n monitor's brightness: %s", index, e.message); | ||
| return -1.0f; | ||
| } | ||
| } | ||
|
|
||
| public void set_monitor_brightness (int index, double value) { | ||
| try { | ||
| gala_brightness_manager.set_monitor_brightness (index, value.clamp (0.0001, 1)); | ||
| } catch (Error e) { | ||
| warning ("Coulnd't set %n monitor's brightness: %s", index, e.message); | ||
| } | ||
| } | ||
|
|
||
|
garaevdi marked this conversation as resolved.
Resolved
|
||
| private void on_monitors_changed () { | ||
| monitors_changed (); | ||
| } | ||
|
|
||
| private void on_monitor_brightness_changed (int index, double value) { | ||
| monitor_brightness_changed (index, value); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright 2026 elementary, Inc. (https://elementary.io) | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
|
leolost2605 marked this conversation as resolved.
Resolved
|
||
|
|
||
| [DBus (name = "io.elementary.gala.BrightnessManager")] | ||
| interface Power.GalaBrightnessManager : GLib.Object { | ||
| public signal void monitors_changed (); | ||
| public signal void monitor_brightness_changed (int index, double value); | ||
|
|
||
| public abstract double get_global_brightness () throws GLib.IOError, GLib.DBusError; | ||
| public abstract double get_monitor_brightness (int index) throws GLib.IOError, GLib.DBusError; | ||
| public abstract string get_monitor_name (int index) throws GLib.IOError, GLib.DBusError; | ||
| public abstract int get_n_monitors () throws GLib.IOError, GLib.DBusError; | ||
| public abstract void set_global_brightness (double scale) throws GLib.IOError, GLib.DBusError; | ||
| public abstract void set_monitor_brightness (int index, double brightness) throws GLib.IOError, GLib.DBusError; | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.