diff --git a/files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js
index 7721819fd2..f9cad6a0bc 100644
--- a/files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js
+++ b/files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js
@@ -15,6 +15,7 @@ const BrightnessBusName = "org.cinnamon.SettingsDaemon.Power.Screen";
const KeyboardBusName = "org.cinnamon.SettingsDaemon.Power.Keyboard";
const CSD_BACKLIGHT_NOT_SUPPORTED_CODE = 1;
+const CSD_SCHEMA = "org.cinnamon.settings-daemon.plugins.power";
const PANEL_EDIT_MODE_KEY = "panel-edit-mode";
@@ -256,7 +257,33 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
this.brightness = new BrightnessSlider(this, _("Brightness"), "display-brightness", BrightnessBusName, 0);
this.keyboard = new BrightnessSlider(this, _("Keyboard backlight"), "keyboard-brightness", KeyboardBusName, 0);
this.menu.addMenuItem(this.brightness);
+
+ this._ambientItem = new PopupMenu.PopupSwitchMenuItem(_("Adjust automatically"), false);
+ this._ambientItem.actor.hide();
+ this.menu.addMenuItem(this._ambientItem);
+
+ this._brightnessSection = new PopupMenu.PopupSeparatorMenuItem();
+ this._brightnessSection.actor.hide();
+ this.menu.addMenuItem(this._brightnessSection);
+
this.menu.addMenuItem(this.keyboard);
+ this._csdSettings = new Gio.Settings({ schema_id: CSD_SCHEMA });
+ this._ambientItem.setToggleState(this._csdSettings.get_boolean("ambient-enabled"));
+ this._ambientItem.connect("toggled", (item) => {
+ this._csdSettings.set_boolean("ambient-enabled", item.state);
+ });
+ this._csdSettings.connect("changed::ambient-enabled", () => {
+ this._ambientItem.setToggleState(this._csdSettings.get_boolean("ambient-enabled"));
+ });
+
+ this.keyboard.actor.connect("notify::visible", () => this._updateBrightnessSeparator());
+
+ Interfaces.getDBusProxyAsync(BrightnessBusName, (proxy, error) => {
+ if (error) return;
+ this._screenProxy = proxy;
+ this._updateAmbientVisibility();
+ this._screenProxy.connect("g-properties-changed", () => this._updateAmbientVisibility());
+ });
try {
// Hadess interface
@@ -340,6 +367,23 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
this.set_show_label_in_vertical_panels(false);
}
+ _updateAmbientVisibility() {
+ if (this._screenProxy && this._screenProxy.AmbientLightSupported) {
+ this._ambientItem.actor.show();
+ } else {
+ this._ambientItem.actor.hide();
+ }
+ this._updateBrightnessSeparator();
+ }
+
+ _updateBrightnessSeparator() {
+ if (this._ambientItem.actor.visible && this.keyboard.actor.visible) {
+ this._brightnessSection.actor.show();
+ } else {
+ this._brightnessSection.actor.hide();
+ }
+ }
+
_onPanelEditModeChanged() {
if (global.settings.get_boolean(PANEL_EDIT_MODE_KEY)) {
if (!this.actor.visible) {
diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
index 81d5087217..e842849a88 100755
--- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
+++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
@@ -267,6 +267,13 @@ def on_module_selected(self):
section = page.add_section(_("Screen brightness"))
section.add_row(BrightnessSlider(section, proxy, _("Screen brightness")))
+ try:
+ ambient_supported = proxy.get_cached_property("AmbientLightSupported")
+ if ambient_supported is not None and ambient_supported.unpack():
+ section.add_row(GSettingsSwitch(_("Adjust automatically"), CSD_SCHEMA, "ambient-enabled"))
+ except Exception as e:
+ print(f"Power module ambient light check failed: {e}")
+
section.add_row(GSettingsSwitch(_("On battery, dim screen when inactive"), CSD_SCHEMA, "idle-dim-battery"))
section.add_reveal_row(GSettingsComboBox(_("Brightness level when inactive"), CSD_SCHEMA, "idle-brightness", IDLE_BRIGHTNESS_OPTIONS, valtype=int, size_group=size_group), CSD_SCHEMA, "idle-dim-battery")
diff --git a/js/misc/interfaces.js b/js/misc/interfaces.js
index 6bdb7b78c2..6981a68fa6 100644
--- a/js/misc/interfaces.js
+++ b/js/misc/interfaces.js
@@ -129,6 +129,7 @@ xml['org.cinnamon.SettingsDaemon.Power.Screen'] =
\
\
\
+ \
\
",
SETTINGS_DAEMON_POWER_NAME,