16

So whenever I hit my dim/brighten keys on the keyboard, a notification bubble pops up with the screen brightness. All that's fine, but I would like to be able to change how much the brightness changes with each key press.

For example, right now it takes just 5 presses to go from the completely dark to the brightest setting. However, I know from the "Brightness/Lock" setting that the screen is capable of much smaller intervals than this.

Is there a way to change how much the brightness jumps each time the keys are pressed?

2
  • Any Ubuntu-specific answer would be appreciated :)
    – Koen
    Aug 16, 2015 at 8:36
  • 1
    The usual brightness scale afaict is 10 steps. If you're seeing 5, it's very likely that something is doubling them up. For example, perhaps Linux is handling the events itself, without realising that they're also passing through to your firmware, which then applies a 2nd increment on the same keypress. Source on this is that it happened to me! I had to add acpi_backlight=vendor to my GRUB boot line, and that sorted it all out. Oct 18, 2015 at 22:37

4 Answers 4

22

Since you haven't specified which desktop environment you use, I'll provide some KDE-specific details as well.

I've just updated KDE to 4.9.2 and met with the same inconvenience. I decided to dig into the code, and here are my conclusions:

  1. Brightness is actually controlled by kernel itself. According to KDE's PowerDevil source code, there exist two basic ways for kernels to provide control interface:
    • sysctl() system call (likely on *BSD systems, I suppose)
    • sysfs interface (likely Linux)
  2. sysfs interface is located at /sys/class/backlight/*your_backlight_type*/. Here's what it looks like for me:
    $ ls -1 /sys/class/backlight/intel_backlight/
    actual_brightness
    bl_power
    brightness
    device
    max_brightness
    power
    subsystem
    type
    uevent
    Two files are relevant for us now: brightness and max_brightness. And here's how they can be used:
    $ cd /sys/class/backlight/intel_backlight
    $ cat max_brightness 
    976
    $ cat brightness 
    176
    $ echo 77 | sudo tee brightness
    77
    
    First command lets you determine the maximum brightness you can set (the minimum is always zero). Second one lets you know what value the actual brightness is set to. And with the third you can set it to any value you desire in the range of [0; max_brightness].
  3. KDE's KRunner still has the freedom to set any brightness level. Press Alt-F2 and type:

    screen brightness 17

  4. KDE's keyboard Brightness Up and Brightness Down key handling code has increment value of 10% hard-coded. Hence, unless you want to mess with building KDE from sources, there's nothing you can do with it.

  5. KDE's BatteryMonitor plasmoid has its own brightness control, whose increment is also hard-coded as 10%, but now we're lucky enough, since it is written in QML: $ sudo nano /usr/share/kde4/apps/plasma/plasmoids/battery/contents/ui/PopupDialog.qml (upd: in KDE 4.11 it has been moved to BrightnessItem.qml), navigate to section that looks like

    Components.Slider {
            id: brightnessSlider
            minimumValue: 0
            maximumValue: 100
            stepSize: 10
            onValueChanged: brightnessChanged(value)
        }
    and change the step size to what you desire. After relogin you'll see the change.

5
  • How to know which is 'your_backlight_type'? (step 2) I have two options, don't know which one to start fiddling with.
    – Koen
    Aug 16, 2015 at 7:14
  • And: Does/How would this work on Ubuntu? (step 4 and/or 5; ie actually setting the brightness interval)
    – Koen
    Aug 16, 2015 at 7:31
  • @koen What are the types present? I'd start with more specific one, but it's only a guess - the internet connection I'm on right now doesn't let me check any docs, will do it later) Re. 4&5: I only use KDE, don't know about Gnome or Unity )
    – vines
    Aug 16, 2015 at 7:58
  • Wow! I had no idea my firmware supported fine-grained brightness control - never mind this fine. I used to use BIOS mode, which could change the level even during boot (to Win7) - but that was the 10-step scale. When I switched to UEFI & Debian/KDE, I saw the same coarse scale, so I assumed it was a hardware limitation. But here I am now, able to tee any number to it for extremely fine control of brightness. Thanks a ton! Oct 18, 2015 at 22:35
  • 3
    P.S.: At least now, KDE's Battery Monitor/Energy Saving, although it steps when clicking, supports near-arbitrary brightness when dragging the slider. Oct 18, 2015 at 22:43
8

This is what I've done, and it works a lot better for me. My screen has a lot of brightness increments, as it's LED backlit and someone thought to take advantage of that.

sudo apt-get install xbacklight
# ..and test it..
xbacklight -dec 20
xbacklight -inc 20
# If this works for you, you can proceed

I'm using KDE, but this applies for Gnome as well. For KDE:

  • Open System Settings
  • Open Shortcuts and Gestures
  • Select Custom Shortcuts in the left bar, if it's not already selected
  • Right-click on a blank part of the list of actions, and select New->Global Shortcut
  • Create one named "Brightness up" and one named "Brightness down"
  • For the trigger, use your brightness-up/down keys. These will conflict with the defaults, but you can just reassign them to this action.
  • For the Action, enter (for example) "xbacklight -inc 3" or "xbacklight -dec 3" (minus quotes)
    • Larger numbers increase/decrease the backlight more, and smaller numbers less.

You can also set a specific percentage:

xbacklight -set 100

Sometimes, an increment or percentage change may have no effect. This is because the hardware only allows specific settings, and the closest setting to the percentage selected is used.

Incidentally, I happily found out that even though this is a more low-level program that is making the change, KDE still recognizes that the screen brightness has changed and displays the brightness percentage appropriately. :-)

2
  • This is also an excellent answer. I can confirm it works on Debian 8.2 with KDE - and that, indeed, KDE is clever enough to notice this and show the OSD. Now to make some shortcuts! Oct 18, 2015 at 22:54
  • I installed xbacklight in ubuntu 18 and it didn't have any affect on the birghtness
    – conteh
    Jun 15, 2022 at 8:36
0

Fine-grained control with hardware brightness switches

Firstly, install xbacklight

$ sudo apt install xbacklight

Secondly, check whether you have control over the backlight.

$ xbacklight -1
$ xbacklight +5

Should these commands result in a No outputs have backlight property error, then follow these remediating steps before proceeding.

Once xbacklight -1 and xbacklight +1 work from the command line, proceed with assigning these commands to respectively the XF86MonBrightnessDown and XF86MonBrightnessUp keys. This is done by hitting those keys when asked by the Settings → Keyboard → Application Shortcuts application.

Finally, reboot for these changes to take effect.

Keyboard settings

0

Use Custom Shortcuts

KDE uses qdbus to change brightness by default, You can add a custom shortcut with the bellow commands to adjust brightness with a custom step

qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl 
org.kde.Solid.PowerManagement.Actions.BrightnessControl.setBrightness $(expr $(qdbus 
org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl 
org.kde.Solid.PowerManagement.Actions.BrightnessControl.brightness) [+ Or -] [Jump step size number])

(Edit the end of the command yourself)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .