4

When I change brightness on the laptop with a laptop keys the brightness is behaving strangely for a couple of minutes, and Xorg eats 5% CPU during this time.

I had the same effect on my previous laptop, which I attributed to its dying hardware. Now I get the same issue after a year usage of my new laptop.

On the first laptop I used proprientary ATI Radeon drivers, and on the current one I use proprientary NVIDIA drivers.

I'm currently using a Kubuntu-dev, but on the old laptop I've used a stable release.

I found a somewhat similar old thread on ubuntu forums with none responces.

Edit

I tried adjusting brightness from cli (see here and there) and also using gui wigdet (I'm on KDE) -- but nothing works: sloppy state frees me faster -- but doesn't change the brightness.

The brightness is only changed with laptop brightness keys, and it takes a couple of minutes to complete that 5% CPU Xorg task.

Adobe
  • 3,891

1 Answers1

2

Solved!

$ find /sys -name "max_brightness"
/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/max_brightness
/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/leds/phy0-led/max_brightness
/sys/devices/platform/dell-laptop/backlight/dell_backlight/max_brightness

$ cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/max_brightness
4648

$ sudo bash -c 'echo 2000 >> /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness'
# note that now it is brightness - not max_brightness

This changes brightness right away! Just as before.

However I still don't know what was wrong.

Edit

The solution might be easily scripted. The only drawback -- it requires root, and I've no idea how to propely set up PolicyKit to do without it.

Edit 2:

I'm using the following script. It has two hardcoded values: Max and BrightnessFile found on lines 17 and 18:

#!/bin/bash
# to get description use the -h flag

# exit after a single error:
set -e


# ================
## default values:

Inc=
Dec=
Set=

Get=false

Max=4648 # max_brightness
BrightnessFile=/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/brightness

Current=`cat $BrightnessFile`


# ===========
## preambula:

PROGNAME=${0##*/}
PROGVERSION=0.01
noColors=false

usage()
{
cat << EO
usage: $PROGNAME [OPTIONS...]

Changes brightness of the laptop.

The value of the max brightness depends on the hardware, and is hardcoded. On my machine it is 4648:

  $ find /sys -name "max_brightness"
  /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/max_brightness
  /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/leds/phy0-led/max_brightness
  /sys/devices/platform/dell-laptop/backlight/dell_backlight/max_brightness

  $ cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-LVDS-1/intel_backlight/max_brightness
  4648

Requires superuser privilages.

Examples:

  Increase brightness by 10 percents:

    $PROGNAME --inc 10

  Decrease brightness by 10 percents:

    $PROGNAME --dec 10

  Set brightness to 10 percents:

    $PROGNAME --set 10

optional arguments:

EO

cat << EO | column -s\& -t

  -i, --inc & increase brightness (in percents)
  -d, --dec & decrease brightness (in percents)
  -s, --set & set brightness (in percents)
 
  -g, --get & print current value (in percents)
  -G, --GUI & ask password with kdialog
 
  -h, --help & show this output
  -v, --version & show version information
EO
}

SHORTOPTS="hvi:d:s:g"
LONGOPTS="help,version,inc:,dec:,set:get"

ARGS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@")

eval set -- "$ARGS"

while true; do
    case $1 in

        -i|--inc)
            Inc=$2; shift;;
        -d|--dec)
            Dec=$2; shift;;
        -s|--set)
            Set=$2; shift;;

        -g|--get)
            Get=true;;

        -h|--help)
            usage; exit 0;;
        -v|--version)
            echo "$PROGVERSION"; exit 0;;
        --)
            shift; break;;
        *)
            shift; break;;
    esac
    shift
done


# =========
## program:

if $Get; then
    CurrentRelVal=`bc <<< "$Current*100/$Max"`
    echo "Current brightness: $CurrentRelVal%"
    exit 0
elif [ -n "$Inc" -a $Inc -eq $Inc 2>/dev/null ]; then
    IncAbsVal=`bc <<< "$Current+$Inc*$Max/100"`
    sudo bash -c "echo $IncAbsVal >> $BrightnessFile"
    exit
elif [ -n "$Dec" -a $Dec -eq $Dec 2>/dev/null ]; then
    DecAbsVal=`bc <<< "$Current-$Dec*$Max/100"`
    sudo bash -c "echo $DecAbsVal >> $BrightnessFile"
    exit 0
elif [ -n "$Set" -a $Set -eq $Set 2>/dev/null ]; then
    SetAbsVal=`bc <<< "$Set*$Max/100"`
    sudo bash -c "echo $SetAbsVal >> $BrightnessFile"
    exit 0
else
    usage
fi
Adobe
  • 3,891