You are not logged in.

#1 2016-09-27 15:34:37

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Make brightness change incrementally? [SOLVED]

Hello everyone,

I just finished setting up some keyboard shortcuts for brightness, since it seems that my new-ish install of the AMDGPU driver doesnt have this working out of the box like catalyst did. The brightness command I've been using in an alias is: alias changebrightness='sudo tee /sys/class/backlight/radeon_bl0/brightness'. This is what I've done to make it work as a shortcut.

1) Setup sudo to allow tee to run without root permissions, and in the brightness directory.

[jbs@dmb-gaming-laptop ~]$ sudo cat /etc/sudoers | grep tee
%wheel ALL=(ALL) NOPASSWD: /usr/bin/tee,/sys/class/backlight/radeon_bl0/brightness
[jbs@dmb-gaming-laptop ~]$ 

2) Change the permissions of /sys/class/backlight/radeon_bl0/brightness, so that I can read/write to it:

[jbs@dmb-gaming-laptop ~]$ ls -l /sys/class/backlight/radeon_bl0/brightness 
-rw-rw-rw- 1 root root 4096 Sep 27 09:21 /sys/class/backlight/radeon_bl0/brightness
[jbs@dmb-gaming-laptop ~]$ 

3) Make the keyboard shortcut for xbindkeys

[jbs@dmb-gaming-laptop ~]$ cat .xbindkeysrc | tail -n8

#Low brightness
"tee /sys/class/backlight/radeon_bl0/brightness <<< 60"
        XF86MonBrightnessDown

#High brightness
"tee /sys/class/backlight/radeon_bl0/brightness <<< 100"
        XF86MonBrightnessUp
[jbs@dmb-gaming-laptop ~]$ 

Now, I just have a high brightness and a low brightness, and both function as intended. However, I would really like to be able to increment the brightness. Say, in increments of 10, tapping brightness up on the keyboard 3 times causes the brightness to go up 30 points. I get an invalid syntax error using negative values for tee, and I'm not sure how to go about adding/subtracting values. Manually inputting the values, as I was doing for a while now, defeats the point of a keyboard shortcut. So what I'm wondering is: How can I make my keyboard shortcuts incrementally change the brightness? Right now, it just jumps between my low/high setting.

Thanks for any help!

Last edited by JohnBobSmith (2016-09-27 23:38:01)


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#2 2016-09-27 15:42:08

tehabe
Member
Registered: 2008-10-14
Posts: 82

Re: Make brightness change incrementally? [SOLVED]

You could try using xbacklight or light instead. See https://wiki.archlinux.org/index.php/backlight for details.

Offline

#3 2016-09-27 15:46:04

Awebb
Member
Registered: 2010-05-06
Posts: 6,291

Re: Make brightness change incrementally? [SOLVED]

1. xblacklight doesn't work?

2. Read the value from brightness to a variable and use either "expr" or bash's builtin arithmetic, like $(( 1 + 1 )).

Offline

#4 2016-09-27 15:53:08

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Make brightness change incrementally? [SOLVED]

Xbacklight does not appear to work with radeon or mode-setting (I'm using both). See the note: https://wiki.archlinux.org/index.php/Ba … xbacklight. I also really dont think installing a package is the solution for everything. Here's my video card:

[jbs@dmb-gaming-laptop ~]$ inxi -G
Graphics:  Card: Advanced Micro Devices [AMD/ATI] Trinity [Radeon HD 7420G]
           Display Server: X.Org 1.18.4 driver: fglrx
           Resolution: 1366x768@60.07hz
           GLX Renderer: Gallium 0.4 on AMD ARUBA (DRM 2.45.0 / 4.7.4-2-ck, LLVM 3.8.1)
           GLX Version: 3.0 Mesa 12.0.3
[jbs@dmb-gaming-laptop ~]$ 

I am most definitely using AMDGPU, the open source (is it open source??) driver. inxi reports fglrx incorrectly on my system for some reason. I'm off to school now. I will try the expressions idea this afternoon.

Have a good day!


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#5 2016-09-27 16:02:57

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Make brightness change incrementally? [SOLVED]

Perhaps you could adopt this https://bbs.archlinux.org/viewtopic.php … 2#p1630252

You would have to change the lines:

...
max_brightness = ReadSysFile("/sys/class/backlight/intel_backlight/max_brightness");
...
brightness = ReadSysFile("/sys/class/backlight/intel_backlight/brightness");
...
if (WriteSysFile("/sys/class/backlight/intel_backlight/brightness",brightness) < 0)

to refer to the appropriate files on your system.  Mine is (obviously) an Intel video system.

Also, read down a couple posts in that other thread for the discussion on SUID

Last edited by ewaller (2016-09-27 16:03:59)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2016-09-27 23:06:41

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Make brightness change incrementally? [SOLVED]

Very nice thanks ewaller! I will try the solutions mentioned and report back as to which ones worked (or not).


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#7 2016-09-27 23:37:18

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Make brightness change incrementally? [SOLVED]

Thanks ewaller that works wonderfully! I was wondering why this line compiled in your program:

   *  program -- this one does not want any.
 x  *
   *  @param[in]     key    An integer that represents a char value of one 

But I figured out that you seem to have a random X in the middle of a comment block in your few month old program wink.

Solved.


I am diagnosed with bipolar disorder. As it turns out, what I thought was my greatest weakness is now my greatest strength.

Everyday, I make a conscious choice to overcome my challenges and my problems. It's not easy, but its better than the alternative...

Offline

#8 2016-09-28 01:57:56

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,797

Re: Make brightness change incrementally? [SOLVED]

Thanks for the feedback, glad it works for you.
Fixed the errant X in the other thread.  I think it is a side effect of my being an emacs user trying to do something with alt-x in a browser   Kind of like when I use vi for a while then switch back to emacs -- I find files with :w in random places. big_smile


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB