How do I adjust the brightness/contrast step size on the shortcuts in KDE?

Hello All,

This is my first post on the Manjaro forums, so please be gentle with me. :smiling_face:

My Dell Latitude laptop that I just recently bought comes with shortcut controls for brightness on the up and down arrows. Now, they DO work, but the increments are set to 10, so the jumps in brightness are quite dramatic. I realize that I can click on the battery icon and bring up a display brightness slider bar, and I can set it to whatever I like. So, call me nit-picky if you like, but I decided this could be a project for me to undertake as a new Linux user to see if there is a way to change the shortcut step size increment as you can with the sound volume step size in the Audio Volume Settings tab.

Now, in all of the research I’ve already done online, I’ve already discovered that I have intel_backlight on my Dell laptop, and a lot of people bring up backlight utilities such as xbacklight, but this only seems relevant to me if you are having an issue adjusting the brightness in the first place.

My issue is not that I cannot adjust the brightness. My issue is that I’m trying to change the shortcuts incremental movement, which, to me, would seem to be more of a keyboard config issue. I mean, to me, you shouldn’t have to add in another utility to change a keyboard shortcut… HOWEVER, I also am not a professional hacker and am just noodling this out on my own.

After weeks of slogging around, I’ve finally created an account so I can ask you guys directly. I probably need to leave some deets about my laptop, so I will try to leave the relevant information below, but if I fail, please bare with me.

Thanks in advance! :v:

  Kernel: 5.15.25-1-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.24.2
    Distro: Manjaro Linux
  Type: Laptop System: Dell product: Latitude E6530 v: 01
    serial: <superuser required>
  Mobo: Dell model: 0JJT5F v: A00 serial: <superuser required> BIOS: Dell
    v: A17 date: 08/19/2015
  Info: dual core Intel Core i5-3340M [MT MCP] speed (MHz): avg: 1264
    min/max: 1200/3400
  Device-1: Intel 3rd Gen Core processor Graphics driver: i915 v: kernel
  Device-2: NVIDIA GF108GLM [NVS 5200M] driver: N/A
  Display: x11 server: X.Org v: driver: X: loaded: intel gpu: i915
    resolution: 1600x900~60Hz
  OpenGL: renderer: Mesa DRI Intel HD Graphics 4000 (IVB GT2)
    v: 4.2 Mesa 21.3.7

I faced a similar problem some time ago. I decided to dig into the code, and here are my conclusions:

KDE’s keyboard Brightness Up and Brightness Down key handling code has a special way of calculating the increment value/step size. Unfortunately that “special way” is hard-coded. Hence, unless you want to mess with building KDE from sources, there’s nothing you can do with it. For me the increment value by using the keyboard keys is 5.

That leaves us with trying out different ways to change brightness with a different increment value.

You can use your mouse and slide over the battery icon to change brightness but we cannot control the increment value there. The files for the battery plasmoid are in /usr/share/plasma/plasmoids/org.kde.plasma.battery.

You can also use krunner to set the brightness. Launch it with Alt+Space and type screen brightness 60 to set the brightness level to 60.

Final and the best way is to install xorg-xbacklight package to change brightness with any value. You can create a custom shortcut for which executes a script everytime it gets active. You put these in ~/.local/bin and make sure they are executable.


#increase brightness with a 5% step value
xbacklight -inc 5

#decrease brightness with a 5% step value
xbacklight -dec 5

@ishaanbhimwal I am willing to accept xbacklight for the win… if I can get my Shortcuts page under System Settings to recognize xbacklight as an application so I can set up keybindings, which it currently does not do.

After installing xorg-xbacklight and testing to see if

$ xbacklight +10
$ xbacklight -5

changes the brightness as mentioned here:
and receiving confirmation that it works in Terminal, the last step I have to do would be to link commands to the up and down arrows for brightness control. The problem is the explanation in the linked page is for XFCE, which apparently handles keybindings differently than KDE. The keybindings page for XFCE looks like this:

which is not what we have in KDE. Ours looks like this:


However, when I go to +Add Application, xbacklight is not recognized. I can see that it is located at /usr/bin/xbacklight and it is listed as an executable, but when I open it, nothing happens. It is not listed under All Applications in the Start Menu, so this is where I’m stuck. Any help would be appreciated.

And that is why I recommended you to make 2 separate scripts as shown in my previous post, put them in ~/.local/bin and make sure they are executable. Next you have to make a custom shortcut. For the keybinding you can use the standard Brightness up or down key only which will then replace it’s normal functionality.

@ishaan2479 Ok, it turns out that since

xbacklight +5
xbacklight -5

already work in Terminal that I don’t have to create separate scripts. I did a little bit more digging after you mentioned Custom Shortcuts.

First, you want to deselect the functionality for Decrease Screen Brightness and Increase Screen Brightness so both have “No active shortcuts,” as shown below:

Next, you go over to Custom Shortcuts>Edit>New>Global Shortcut>Command/URL. I set up two new shortcuts I named Screen Brightness Up and Screen Brightness Down, as shown below:

Now, I initially wanted the steps to be in +/- 2 increments, but it turns out that there is still some other active script likely working because the increments were not working correctly. (I already had suspected that more than one script was running when using the default Up/Down arrows for brightness because the 10 increment steps that were happening were stuttering – first it did 5, then it did another 5 extremely quickly as if two different actions were taking place when pushing the button just once.)

So, too, I was running into the same problem with +/- 2 increment steps. Sometimes it went up 2. Other times it went up 3. I decided to try it at +/- 5 increment steps because I hoped that would help, but it was still going up 5 sometimes, 6 others. Since the screen brightness change is more noticeable at +/- 5, I decided to fix the problem from there. Since I don’t know what the real value is that the other active script is using, I just played with some numbers and settled at this in the Command/URL line under the Action tab:

xbacklight +4.2
xbacklight -4.2

These integers yielded the result of the new Up and Down shortcuts giving me the incremental movement I was looking for: i.e. from 30% to 35, 40, etc. and 25, 20, and so on downwards. (Correction: It still seems to be off slightly every once and a while since I don’t know what integer the other script is using, but it works pretty well for me.)

I guess I will call this a win for now, but there is definitely another solution to be had, especially if another script is still in use somewhere. Perhaps this is something I will revisit once I have immersed myself into Terminal use more in the future.

Until then, thank you for you help, @ishaan2479, you made me take a second look at an area I hadn’t looked at closely enough, and revisiting it finally got me a solution.

If anyone else knows the more direct path, please let me know.

I’m still a little disappointed because while I got the shortcuts to work for the most part, they no longer have a visual screen pop-up display showing the brightness incremental change as is tied to the original shortcuts. So, unless you click on the battery to view the display brightness there, you don’t actually visually see the change you are affecting with the new shortcuts. Oh well for now! lol

xbacklight +5 && notify-send "Brightness - $(xbacklight -get | cut -c1-2)%"              

Ok, so I added that command on to my shortcuts, and it IS giving me a visual notification… the only problem is that since there are two scripts running, it’s doubling the notification message for my step and the hidden step as show below:

Without knowing what the other script is that is still running, it would likely be difficult to get only one notification to appear, I’m guessing?

Also, do you know if there is a way to link the new shortcuts to the original notification box? (as shown below):

@ishaan2479 I truly appreciate your assistance! :smile:

$(xbacklight -get | cut -c1-2)%

This results in the decimal place showing still for single digit screen brightnesses. 9.%

$(xbacklight -get | cut -f1 -d.)% will split the text at the decimal and return the first element, so only whatever is before the decimal place.

You can also add -a Brightness to the notify-send command to set the title bar text of the notification. This is the full notification command I am using.
notify-send -e -t 500 -a "Brightness" "$(xbacklight -get | cut -f1 -d.)%"