Skip to content

Commit 5e8dddb

Browse files
committed
Deprecate XRandr method
XRandr will be removed in the next release. There are a couple of reasons to deprecate XRandr: 1. X11 only Xrandr doesn't support Wayland, and X11 is EOL. Gnome, Fedora and Ubuntu have dropped X11, and KDE is going to sometime soon. 70% of KDE users are on Wayland anyway. 2. It doesn't change backlight, only gamma This has been a longstanding issue which is that xrandr doesn't change the backlight, it applies a gamma filter. This meant you could accidentally dim your screen "twice" with different brightness methods and not realise how to fix it. This is confusing behaviour and isn't what this library should do. 3. Functionality has been superseded XRandr simply isn't needed any more. The SysFiles and I2C classes both cover pretty much all displays, with DDCUtil covering USB displays. It's just not required anymore. I'll probably publish a release with the deprecation warning in place and then remove it in the next one, or in a few months, whichever comes first
1 parent 5ec8bee commit 5e8dddb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docs/source/extras/Installing On Linux.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
[1] While both DDCUtil and the 1st party `linux.I2C` class do similar things over the same interface (I2C),
6161
DDCUtil also supports communicating with monitors that implement the [Monitor Control Command Set over USB](https://www.ddcutil.com/usb)
6262
63-
[2] Xrandr has two key limitations. It doesn't support Wayland and it doesn't actually change the backlight of the display, it just changes the brightness by applying a filter to the pixels to make them look dimmer/brighter.
63+
[2] The use of Xrandr by this library is deprecated and will be removed in a future release.
64+
Xrandr doesn't support Wayland and it doesn't actually change the backlight of the display, it just changes the brightness by applying a filter to the pixels to make them look dimmer/brighter.
6465
6566
6667
## Install Instructions

screen_brightness_control/linux.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
import time
99
from typing import List, Optional, Tuple
10+
import warnings
1011

1112
from . import filter_monitors, get_methods
1213
from .exceptions import I2CValidationError, NoValidDisplayError, format_exc
@@ -431,7 +432,15 @@ def set_brightness(cls, value: IntPercentage, display: Optional[int] = None):
431432

432433

433434
class XRandr(BrightnessMethodAdv):
434-
'''collection of screen brightness related methods using the xrandr executable'''
435+
'''
436+
.. warning:: Deprecated
437+
The XRandr brightness method has been deprecated and will be removed in a future release.
438+
XRandr only works on X11, which is starting to be dropped by most distributions.
439+
Furthermore, the xrandr executable doesn't change backlight brightness like the other methods here,
440+
but changes the gamma instead, making the behaviour inconsistent with the rest of the library.
441+
442+
Collection of screen brightness related methods using the xrandr executable
443+
'''
435444

436445
executable: str = 'xrandr'
437446
'''the xrandr executable to be called'''
@@ -549,6 +558,7 @@ def get_display_info(cls, display: Optional[DisplayIdentifier] = None, brightnes
549558

550559
@classmethod
551560
def get_brightness(cls, display: Optional[int] = None) -> List[IntPercentage]:
561+
warnings.warn('The xrandr method is deprecated. Please use another brightness method', DeprecationWarning)
552562
monitors = cls.get_display_info(brightness=True)
553563
if display is not None:
554564
monitors = [monitors[display]]
@@ -558,6 +568,7 @@ def get_brightness(cls, display: Optional[int] = None) -> List[IntPercentage]:
558568

559569
@classmethod
560570
def set_brightness(cls, value: IntPercentage, display: Optional[int] = None):
571+
warnings.warn('The xrandr method is deprecated. Please use another brightness method', DeprecationWarning)
561572
value_as_str = str(float(value) / 100)
562573
info = cls.get_display_info()
563574
if display is not None:

0 commit comments

Comments
 (0)