Wednesday, May 15, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1259  / 2 Years ago, tue, june 21, 2022, 9:35:51

I just run Ubuntu 21.04 in live mode to test before a full installation on an XPS 15 9510 with the OLED screen, but I cannot control the screen brightness, I know there is an issue with OLED screens from many years ago, nonetheless I thought at this point it was already solved. Dell provides a temporary workaround via the terminal, but it is not very practical:


https://www.dell.com/support/kbdoc/en-uk/000129708/can-t-change-the-oled-s-brightness-on-precision-xps-systems-once-you-ve-installed-ubuntu-linux


Any suggestion on how to solve this? Thanks


More From » dell

 Answers
7

I've created a script that enables you to create custom keyboard shortcuts using the suggested Dell solution for adjusting screen brightness:


https://gist.github.com/lagerone/1568ea6fbb98fd90a3495f9e51e26c8c


You might need to modify it, as the script assumes the laptop screen name is eDP-1. Run xrandr to find out your screen name and modify this line accordingly:


subprocess.run(["xrandr", "--output", "eDP-1", "--brightness", str(adjusted_level)])

Here's the full script:


#!/usr/bin/python3

import logging
import os
import subprocess
import sys
from typing import Literal

logging.basicConfig(level=logging.DEBUG)

FILE_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), ".screen-brightness"
)


def read_current_level() -> float:
if not os.path.isfile(FILE_PATH):
return 1
with open(
file=FILE_PATH,
mode="r",
encoding="utf-8",
) as file:
current_level = file.readline().strip()
return float(current_level)


def save_level(level: float) -> None:
with open(
file=FILE_PATH,
mode="w",
encoding="utf-8",
) as file:
file.write(str(level))


def adjust_level(method: Literal["up", "down"]) -> None:
adjuster = 0.05 if method == "up" else -0.05
current_level = read_current_level()
adjusted_level = current_level + adjuster
if adjusted_level > 1:
adjusted_level = 1
if adjusted_level < 0.2:
adjusted_level = 0.2
logging.debug(f"Setting screen brightness to {adjusted_level}.")
subprocess.run(["xrandr", "--output", "eDP-1", "--brightness", str(adjusted_level)])
save_level(level=adjusted_level)


if __name__ == "__main__":
METHOD = sys.argv[1] if len(sys.argv) > 1 else "up"
adjust_level(method=METHOD)

[#1251] Tuesday, June 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bsorbedeldy

Total Points: 315
Total Questions: 110
Total Answers: 108

Location: Reunion
Member since Mon, Dec 28, 2020
3 Years ago
;