You are not logged in.

#1 2014-04-15 23:27:53

hjpbarcelos
Member
Registered: 2014-04-15
Posts: 5

Brightness adjustment keys not working on Gnome 3.12

I'm aware of these two threads:

https://bbs.archlinux.org/viewtopic.php?id=180050
https://bbs.archlinux.org/viewtopic.php?id=178014

But they didn't help me to solve my problem.

Since ACPI seems not to be working properly, can change my screen brightness using intel_backlight.

I've actually created a little piece of code to make things easier.

#!/bin/bash

if [[ $UID != 0 ]]; then
    echo "Please run this script with sudo:"
    echo "sudo $0 $*"
    exit 1
fi

FILE=/sys/class/backlight/intel_backlight/brightness
VAL=$(($(<${FILE})))

getopts i:d:s: OPTION
case "${OPTION}" in
    s) VAL=$((${OPTARG} * 4882 / 100)) ;;
    i) VAL=$((${VAL} + ${OPTARG} * 4882 / 100));;
    d) VAL=$((${VAL} - ${OPTARG} * 4882 / 100));;
    *) exit 1
esac

if [ $VAL -gt 4882 ]; then
    VAL=4882
fi

if [ $VAL -lt 0 ]; then
    VAL=0
fi

sudo echo $VAL > $FILE

I've altered my /etc/sudoers file to allow this script to run as sudo without requiring a password.

The script works fine if I call it from a terminal or from ATL+F2.

Then I tried to add this to gnome's custom keyboard shortcuts, but it doesn't work.

I've put this as the command to be executed:

sudo /home/henrique/bin/brightness -i 5

And configured the proper key, but it doesn't work.

Any ideas?

Offline

#2 2014-04-17 00:55:45

Kopkins
Member
Registered: 2012-07-01
Posts: 189

Re: Brightness adjustment keys not working on Gnome 3.12

You can't run a sudo command except from the command line if you want to input your password. You could use gksudo if you want a password promt pop-up window.

Or you could set keys in gnome to run xbacklight.

For brightness up use:

xbacklight -inc 10

You can put whatever increment you want instead of 10.

For decrease:

xbacklight -dec 10

Offline

Board footer

Powered by FluxBB