cosmic-applets icon indicating copy to clipboard operation
cosmic-applets copied to clipboard

[Power/Brightness] Integrate external monitor brightness controls

Open joewood9364 opened this issue 1 year ago • 11 comments

https://github.com/davidhi7/ddcci-plasmoid The above KDE plasmoid allows users to change external monitor brightness which is very useful but also not very easy to install and does not integrate into KDE's native brightness adjustment sliders.

Ideally brightness adjustment of monitors would be a native feature akin to laptop screen brightness adjustment - COSMIC having this functionality by default would be a welcome improvement over competing DEs.

joewood9364 avatar May 10 '24 23:05 joewood9364

This definitely would be nice to have.

We'd need to decide how to handle multiple brightness devices.

  • The applet presumably should have sliders for each output, but key bindings are less clear.
  • If a laptop is connected to an external output, do brightness key bindings change the laptop display brightness?
    • What if only the external monitor is enabled?
  • What if a desktop has two external monitors?
    • If they're identical models changing the brightness together could work quite nicely, but that may not work well with different monitor models.

ids1024 avatar Jun 18 '24 15:06 ids1024

I guess key bindings could trigger the display where the mouse is. And there could be an option to control all monitors at the same time

wiiznokes avatar Jun 18 '24 15:06 wiiznokes

I would like to personally see something like monitorian's controls on windows, except a bit more sleek, A single brightness control with a dropdown menu perhaps, drop down to control each monitor individually, and when not dropped down, a single slider to control the brightness of all monitors in relation to the brightness set by the individual sliders.

https://github.com/emoacht/Monitorian

monitorian for reference, in the readme they have a video showcasing it working

key bindings can be just for the "global" control in this case

Quackdoc avatar Jun 18 '24 15:06 Quackdoc

I see ddcutil is also quite slow to get or set brightness or other settings. Apparently this is expected: https://www.ddcutil.com/faq

ddcutil spends 90% of its elapsed time in waits mandated by the DDC/CI protocol.

That may be awkward with a slider?

That also mentions a couple issues with certain monitors, unsurprisingly. Not sure how consistently to expect things to work with DDC/CI. Does any OS or desktop environment currently expose it prominently, by default, for all monitors that support it?

ids1024 avatar Jun 18 '24 15:06 ids1024

I see ddcutil is also quite slow to get or set brightness or other settings. Apparently this is expected: https://www.ddcutil.com/faq

ddcutil spends 90% of its elapsed time in waits mandated by the DDC/CI protocol.

That may be awkward with a slider?

That also mentions a couple issues with certain monitors, unsurprisingly. Not sure how consistently to expect things to work with DDC/CI. Does any OS or desktop environment currently expose it prominently, by default, for all monitors that support it?

Maybe this is useful: https://github.com/daitj/gnome-display-brightness-ddcutil/issues/137

"Response times with ddcutil are slow - use DDCControl DBUS service if available"

onlyreportingissues avatar Jun 18 '24 15:06 onlyreportingissues

So it can be faster if some persistent service keeps open a DDC connection? That may be doable.

ids1024 avatar Jun 19 '24 02:06 ids1024

I see ddcutil is also quite slow to get or set brightness or other settings. Apparently this is expected: https://www.ddcutil.com/faq

ddcutil spends 90% of its elapsed time in waits mandated by the DDC/CI protocol.

That may be awkward with a slider?

That also mentions a couple issues with certain monitors, unsurprisingly. Not sure how consistently to expect things to work with DDC/CI. Does any OS or desktop environment currently expose it prominently, by default, for all monitors that support it?

I have tried this applet for a few days now & it works fine (with no delays): https://github.com/maciekk64/cosmic-ext-applet-external-monitor-brightness

onlyreportingissues avatar Jul 28 '24 18:07 onlyreportingissues

I've written a DBUS ddcutil-service that interfaces to libddcutil. Using ddcutil-service/libddcutil is far faster than using the ddcutil command.

I've also written an example Qt vdu_controls application that use either ddcutil-service or the ddcutil-command. It might be a source of ideas for an applet. For example, it has a lux-level slider to adjust multiple monitors according to per-monitor lux/brightness curves.

(Apologies for being a bit late to this discussion, I tripped over this issue while doing a recent google-search.)

digitaltrails avatar Apr 19 '25 00:04 digitaltrails

https://github.com/maciekk64/cosmic-ext-applet-external-monitor-brightness

~Unfortunately the applet is archived~ (EDIT: there is a replacement: https://github.com/cosmic-utils/cosmic-ext-applet-external-monitor-brightness)

~and seems to no longer work -- I don't get any brightness controls at all, only the dark/light theme switch~ (EDIT: apparently the package I installed was indeed of https://github.com/cosmic-utils/cosmic-ext-applet-external-monitor-brightness, so maybe this is some kind of a NixOS packaging problem) (EDIT 2: the packaged version turned out to be quite old, I'll try updating it and seeing whether it works better)

ada4a avatar Oct 16 '25 14:10 ada4a

~and seems to no longer work

@ada4a I've got it working fine for myself on NixOS

NixOS setup - kind of off topic but maybe this is helpful to you

In configuration.nix

  hardware.i2c.enable = true;
  boot.kernelModules = ["i2c-dev"];
  services.udev.extraRules = ''
        # Enable ddc monitor brightness control
        KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
  '';

Then I have a package for building the brightness control widget.

File packages/cosmic-ext-applet-external-monitor-brightness/default.nix:

{
  lib,
  stdenv,
  rustPlatform,
  fetchFromGitHub,
  libcosmicAppHook,
  just,
  openssl,
  nix-update-script,
  pkg-config,
  systemd,
}:
rustPlatform.buildRustPackage rec {
  pname = "cosmic-ext-applet-external-monitor-brightness";
  version = "0.1.0";

  src = fetchFromGitHub {
    owner = "cosmic-utils";
    repo = "cosmic-ext-applet-external-monitor-brightness";
    rev = "23104965bd9ab1988b040a60f3f1e5d64038e7ce";
    hash = "sha256-+Hu9bLEbue9bXaGfKa3InhdFI6qsBxccyQY8qzBYFPk=";
  };

  cargoHash = "sha256-ou7iukl1pHMfcJNemwLdZYYxugbJJQ53XpCYowUTj90=";

  nativeBuildInputs = [
    pkg-config
    libcosmicAppHook
    just
  ];

  buildInputs = [
    openssl
    systemd
  ];

  justFlags = [
    "--set"
    "prefix"
    (placeholder "out")
    "--set"
    "bin-src"
    "target/release/cosmic-ext-applet-external-monitor-brightness"
  ];

  meta = {
    description = "Change brightness of external monitors via DDC/CI protocol. You can also quickly toggle system dark mode.";
    homepage = "https://github.com/cosmic-utils/cosmic-ext-applet-external-monitor-brightness";
    license = lib.licenses.gpl3Only;
    mainProgram = "cosmic-ext-applet-external-monitor-brightness";
    platforms = lib.platforms.linux;
    sourceProvenance = [ lib.sourceTypes.fromSource ];
  };
}

Include the package in your system configuration. In my case via home manager:

home.packages = with pkgs; [
    (callPackage ../packages/cosmic-ext-applet-external-monitor-brightness { })
  ];

gilest avatar Oct 16 '25 22:10 gilest

Ah, nice! Thank you @gilest :)

ada4a avatar Oct 17 '25 05:10 ada4a