I tried changing the brightness but it won't dim or brighten using keys or going under applications, it just stays the same.
Ubuntu – Brightness wont change
appearancebrightness
Related Solutions
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:
- 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)
- 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
andmax_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]
. KDE's KRunner still has the freedom to set any brightness level. Press Alt-F2 and type:
screen brightness 17
KDE's keyboard
Brightness Up
andBrightness 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.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 toBrightnessItem.qml
), navigate to section that looks likeComponents.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.
Introduction
The script below is modified version of my previous scripts, written in python and using dbus exclusively for polling ac_adapter presence and setting the screen brightness.
Usage
Usage is simple: call from command line as
python ./brightness_control.py
The script defaults to 100% brightness on AC , 10% on battery. Users can use -a
and -b
to set their desired brightness levels on ac and battery respectively.
AS given by -h
option:
$ ./brightness_control.py -h
usage: brightness_control.py [-h] [-a ADAPTER] [-b BATTERY]
Simple brightness control for laptops,
depending on presense of AC power supply
optional arguments:
-h, --help show this help message and exit
-a ADAPTER, --adapter ADAPTER
brightness on ac
-b BATTERY, --battery BATTERY
brightness on battery
For example, one can do any of the following:
# set non default for brightness on ac
$ ./brightness_control.py -a 80
# set non-default value for brightness on battery
$ ./brightness_control.py -b 20
# set non-default values for both
$ ./brightness_control.py -a 80 -b 20
Source
Also available on GitHub
#!/usr/bin/env python
"""
Author: Serg Kolo <1047481448@qq.com>
Date: Nov 3rd , 2016
Purpose:Brightness control depending on
presence of ac adapter
Written for: http://askubuntu.com/q/844193/295286
"""
import argparse
import dbus
import time
import sys
def get_dbus_property(bus_type, obj, path, iface, prop):
""" utility:reads properties defined on specific dbus interface"""
if bus_type == "session":
bus = dbus.SessionBus()
if bus_type == "system":
bus = dbus.SystemBus()
proxy = bus.get_object(obj, path)
aux = 'org.freedesktop.DBus.Properties'
props_iface = dbus.Interface(proxy, aux)
props = props_iface.Get(iface, prop)
return props
def get_dbus_method(bus_type, obj, path, interface, method, arg):
""" utility: executes dbus method on specific interface"""
if bus_type == "session":
bus = dbus.SessionBus()
if bus_type == "system":
bus = dbus.SystemBus()
proxy = bus.get_object(obj, path)
method = proxy.get_dbus_method(method, interface)
if arg:
return method(arg)
else:
return method()
def on_ac_power():
adapter = get_adapter_path()
call = ['system','org.freedesktop.UPower',adapter,
'org.freedesktop.UPower.Device','Online'
]
if get_dbus_property(*call): return True
def get_adapter_path():
""" Finds dbus path of the ac adapter device """
call = ['system', 'org.freedesktop.UPower',
'/org/freedesktop/UPower','org.freedesktop.UPower',
'EnumerateDevices',None
]
devices = get_dbus_method(*call)
for dev in devices:
call = ['system','org.freedesktop.UPower',dev,
'org.freedesktop.UPower.Device','Type'
]
if get_dbus_property(*call) == 1:
return dev
def set_brightness(*args):
call = ['session','org.gnome.SettingsDaemon.Power', '/org/gnome/SettingsDaemon/Power',
'org.gnome.SettingsDaemon.Power.Screen', 'SetPercentage', args[-1]
]
get_dbus_method(*call)
def parse_args():
info = """
Simple brightness control for laptops,
depending on presense of AC power supply
"""
arg_parser = argparse.ArgumentParser(
description=info,
formatter_class=argparse.RawTextHelpFormatter)
arg_parser.add_argument(
'-a','--adapter',action='store',
type=int, help='brightness on ac',
default=100,
required=False)
arg_parser.add_argument(
'-b','--battery',action='store',
type=int, help='brightness on battery',
default=10,
required=False)
return arg_parser.parse_args()
def main():
args = parse_args()
while True:
if on_ac_power():
set_brightness(args.adapter)
while on_ac_power():
time.sleep(1)
else:
set_brightness(args.battery)
while not on_ac_power():
time.sleep(1)
if __name__ == "__main__": main()
Best Answer
Check which graphics driver is used to control the brightness
ls /sys/class/backlight/
if it responds with a list that includes
intel_backlight
proceed - if not, I can't help youIf you have the intel_backlight then
Add the lines
Logout, and log back in - your backlight should work now. I got this answer from itsfoss.com