LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 10-22-2012, 09:15 AM   #1
Ipe
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Rep: Reputation: Disabled
Brightness control not working.


I'm a Slackware newbie. I install Slackware 14 x64 on a Toshiba L750 laptop. Screen is too bright, can't change it using brightness control (on panel). I'm using KDE.

Last edited by Ipe; 10-22-2012 at 09:18 AM. Reason: add info
 
Old 10-22-2012, 10:06 AM   #2
dr.s
Member
 
Registered: Feb 2010
Distribution: Slackware64
Posts: 135

Rep: Reputation: 20
You should be able to change it in KDE using main menu --> System Settings --> Power Management, or if laptop is running on battery you'll see a battery icon in the lower right hand corner, click on it and use the Screen Brightness slider
or you can try this from the console (as root), first 2 commands display the max brightness and brightness levels on my machine, last command sets it to a new value.
Quote:
cat /sys/class/backlight/intel_backlight/max_brightness
4882

cat /sys/class/backlight/intel_backlight/brightness
1416

echo 2000 > /sys/class/backlight/intel_backlight/brightness

Last edited by dr.s; 10-22-2012 at 10:08 AM.
 
1 members found this post helpful.
Old 10-22-2012, 02:02 PM   #3
DrCube
LQ Newbie
 
Registered: Oct 2012
Posts: 16

Rep: Reputation: 3
Can I piggyback on this question?

Basically, I want to do the same thing in i3wm. I can make keyboard shortcuts in .i3/config, but I don't know what program to call from there. Also, I'd like some indicator of what the current brightness level is in i3bar.

Thanks.
 
Old 10-22-2012, 06:52 PM   #4
Ipe
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
the console command works. thank you dr.s!
But how could i make my setting permanent or default?
i wonder why the Screen Brightness slider in power management
or in the battery monitor not working.

Last edited by Ipe; 10-23-2012 at 11:22 AM.
 
Old 10-26-2012, 08:44 AM   #5
DrCube
LQ Newbie
 
Registered: Oct 2012
Posts: 16

Rep: Reputation: 3
Quote:
Originally Posted by DrCube View Post
Can I piggyback on this question?

Basically, I want to do the same thing in i3wm. I can make keyboard shortcuts in .i3/config, but I don't know what program to call from there. Also, I'd like some indicator of what the current brightness level is in i3bar.

Thanks.
Here's what I did: First, I read the thread. I originally skimmed over Dr.S's post because I saw "KDE menu" and thought it didn't apply to me. But he basically told me what to do. Only my computer uses "acpi_video0/brightness" between 1-8 rather than "intel_backlight/brightness" between 0 and 4882.

So, I wrote two scripts, bright_up and bright_down:

bright_up
Code:
#! /bin/bash

max_brightness=$(cat /sys/class/backlight/acpi_video0/max_brightness)
brightness=$(cat /sys/class/backlight/acpi_video0/brightness)

if (($brightness<$max_brightness))
then
     let brightness=$brightness+1

fi

echo $brightness > /sys/class/backlight/acpi_video0/brightness
bright_down
Code:
#! /bin/bash

max_brightness=$(cat /sys/class/backlight/acpi_video0/max_brightness)
brightness=$(cat /sys/class/backlight/acpi_video0/brightness)

if (($brightness>0))
then
     let brightness=$brightness-1

fi

echo $brightness > /sys/class/backlight/acpi_video0/brightness
Then, chmod +x both of those files, and put the following in my .i3/config:

Code:
# Brightness control
bindsym $mod+F9 exec /home/drcube/.i3/bright_up
bindsym $mod+F8 exec /home/drcube/.i3/bright_down
The thing is, my brightness function keys don't work. I need the System 76 driver, and I haven't figured out how to port that over from Ubuntu yet. So, I just used mod+the function keys that should control brightness.

Finally, root owns that brightness file (/sys/class/backlight/acpi_video0/brightness), and you can't chown permanently because the file gets rebuilt every time you boot. So, I put this in my /etc/rc.d/rc.local:

Code:
chown <user>:users /sys/class/backlight/acpi_video0/brightness
where <user> is me.

I still haven't figured out how to indicate the brightness level in i3bar. And I know this is probably way too much info for what I actually did, but hopefully the next person can google this and get up and running pretty fast. I tried to lay it all out there.
 
2 members found this post helpful.
Old 10-26-2012, 09:40 AM   #6
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 14.1 64 Multi-Lib
Posts: 443

Rep: Reputation: 140Reputation: 140
@DrCube: I think chowning that device to your user is probably not a good idea. Please read up on the "sudo" command, and add the appropriate entries in the /etc/sudoers.conf file.
 
Old 10-26-2012, 11:10 AM   #7
DrCube
LQ Newbie
 
Registered: Oct 2012
Posts: 16

Rep: Reputation: 3
Quote:
Originally Posted by Mark Pettit View Post
@DrCube: I think chowning that device to your user is probably not a good idea. Please read up on the "sudo" command, and add the appropriate entries in the /etc/sudoers.conf file.
Please fight my ignorance here, because I don't see how this would work. Can I really use sudo to allow a single program (i3) the ability to edit a single root-owned file (/sys/class/backlight/acpi_video0/brightness)? Without needing a password?

I'm not saying you're wrong, I'm just saying:

1) I don't know how to do it with sudo, and
b) even if I could, it seems more dangerous to elevate i3's privileges than for a user to take ownership of a single, fairly harmless, file.

I don't want my window manager to have any extra privileges that I as a user don't have, except the ability to write to /sys/class/backlight/acpi_video0/brightness.
 
Old 10-26-2012, 02:28 PM   #8
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Hi,

this thread inspired me to find out how I can control the backlight on my Samsung laptop. The function-keys for the backlight don't work. Thanks to the posting above I found out that
Code:
echo > "value" /sys/class/backlight/acpi_video0/brightness
really sets the backlight.

I've written the following script
Code:
#!/bin/bash

yet=`cat /sys/class/backlight/acpi_video0/actual_brightness`
max=`cat /sys/class/backlight/acpi_video0/max_brightness`

bl_up() {
    if [ $yet -lt $max ]; then
        let new=$yet+1
        echo $new > /sys/class/backlight/acpi_video0/brightness
    else
        echo "Helligkeit ist schon maximal"
    fi
}

bl_down() {
    if [ $yet -gt 0 ]; then
        let new=$yet-1
        echo $new > /sys/class/backlight/acpi_video0/brightness
    else
        echo "Noch dunkler geht nicht"
    fi
}

case "$1" in
    'h')
        bl_up
        ;;
    'd')
        bl_down
        ;;
    'z')
        echo "aktuelle Helligkeit $yet von $max"
        ;;
    *)
        echo "screen.sh h (heller) | d (dunkler) | z (aktueller Wert)"
esac
which works. But I wanted to configure some keybindings for this. I'm using xmonad as windowmanager. In my ~/.xmonad/xmonad.hs I have added the following two lines:
Code:
 ,((mod4Mask, xK_Up), spawn "/usr/local/bin/screen.sh h")
 ,((mod4Mask, xK_Down), spawn "/usr/local/bin/screen.sh d")
Now I can set the backlight with <Windows>+<Cursor Up> and <Windows>+<Cursor Down>

Markus
 
1 members found this post helpful.
Old 10-27-2012, 08:13 AM   #9
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 14.1 64 Multi-Lib
Posts: 443

Rep: Reputation: 140Reputation: 140
Quote:
Originally Posted by DrCube View Post
Please fight my ignorance here, because I don't see how this would work. Can I really use sudo to allow a single program (i3) the ability to edit a single root-owned file (/sys/class/backlight/acpi_video0/brightness)? Without needing a password?
That is EXACTLY what sudo can be setup to achieve. I'm speaking from memory here, but you can setup the sudoers.conf file to say something like :
Allow userx to run "abc def ghi 123" without a password. You can configure it to ask a password, but in this case it would be unhelpful. The sudoers method is far safer than anything else. I work in a large(ish) Unix environment (Solaris servers), and we use sudo to allow lower level users access to commands that would otherwise require root permissions.
 
Old 10-28-2012, 09:36 AM   #10
dr.s
Member
 
Registered: Feb 2010
Distribution: Slackware64
Posts: 135

Rep: Reputation: 20
@DrCube and @markush, thanks for the script samples!

Quote:
Originally Posted by DrCube View Post
Please fight my ignorance here, because I don't see how this would work. Can I really use sudo to allow a single program (i3) the ability to edit a single root-owned file (/sys/class/backlight/acpi_video0/brightness)? Without needing a password?

I'm not saying you're wrong, I'm just saying:
1) I don't know how to do it with sudo, and
b) even if I could, it seems more dangerous to elevate i3's privileges than for a user to take ownership of a single, fairly harmless, file.

I don't want my window manager to have any extra privileges that I as a user don't have, except the ability to write to /sys/class/backlight/acpi_video0/brightness.
@DrCube, as suggested in Mark's post, you don't need to chown, use something like the following, it will prompt you for a password:
Code:
su -c "echo $brightness > /sys/class/backlight/acpi_video0/brightness"
 
Old 10-28-2012, 09:43 AM   #11
dr.s
Member
 
Registered: Feb 2010
Distribution: Slackware64
Posts: 135

Rep: Reputation: 20
Quote:
Originally Posted by Ipe View Post
the console command works. thank you dr.s!
But how could i make my setting permanent or default?
i wonder why the Screen Brightness slider in power management
or in the battery monitor not working.
Not sure about the power management issue on your machine. You can add the command that worked for you to /etc/rc.d/rc.local so it will kick in at startup.
 
Old 10-31-2012, 12:01 PM   #12
Ipe
LQ Newbie
 
Registered: Oct 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks dr.s. I think I'm gonna like it here (the forum). You guys are very helpful. It's a nice learning experience.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
brightness control issue? vetrib2w Linux - Laptop and Netbook 3 04-13-2010 11:58 PM
Brightness control Keys not working ravisagar Fedora 0 07-18-2009 11:53 PM
Brightness control on laptops. YodaSlack Linux - Hardware 7 01-24-2008 03:56 PM
Screen brightness control function keys not working. Gargle Slackware 5 07-22-2007 06:59 AM
VAIO VGN-S5M/S: Memory stick drive & brightness control not working on Suse 10.1 fisayo Linux - Laptop and Netbook 6 01-24-2007 12:00 PM


All times are GMT -5. The time now is 03:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration