How to Configure Screen Brightness in mate on pinebook via terinal?
#1
I'm trying to bind brightness change to buttons via terminal in i3, but I can't find a command that will doing that:
Code:
[email protected]:~$ sudo xrandr --listmonitors

Output is:

xrandr: Failed to get size of gamma for output default

Monitors: 1
 0: +*default 1366/361x768/203+0+0  default

So, when I trying to change it like:
Code:
[email protected]:~$ sudo xrandr --output default --brightness 0.5

It isn't do anything. 

Code:
[email protected]:~$ echo 240 > /sys/class/backlight/lcd0/brightness


Have not do anything too Sad
  Reply
#2
I found this, but it is not working with sudo, only after sudo su

Code:
[email protected]:/home/pine64# echo 50 > /sys/class/backlight/lcd0/brightness

Okay, now is the question how to make my own xbacklight with -dec 10 and -inc 10 to bind this for keyboard keys Smile
  Reply
#3
(08-31-2017, 12:28 PM)shirman Wrote: I found this, but it is not working with sudo, only after sudo su

Code:
[email protected]:/home/pine64# echo 50 > /sys/class/backlight/lcd0/brightness

Okay, now is the question how to make my own xbacklight with -dec 10 and -inc 10 to bind this for keyboard keys Smile


... two scripts , one for key +  one for key -

Your script needs to read the value into a variable ,  add 10 to it ,  and then write the variable back out;  but, only if the +10 will not exceed 100.

Do the same for the minus key binding, only don't allow it to go below say 30 ( idk, experiment ).

also,  try:    sudo  -i


Shy

Ok, here are the scripts :



lcd_plus.sh

Code:
#!/bin/bash

LCDVALUE=`cat /sys/class/backlight/lcd0/brightness`
NEWVALUE=$(( $LCDVALUE + 10 ))

if [ $NEWVALUE -le 100 ]
then
   echo $NEWVALUE > /sys/class/backlight/lcd0/brightness
   echo $NEWVALUE
else
   echo $LCDVALUE
fi


lcd_minus.sh

Code:
#!/bin/bash

LCDVALUE=`cat /sys/class/backlight/lcd0/brightness`
NEWVALUE=$(( $LCDVALUE - 10 ))

if [ $NEWVALUE -gt 30 ]
then
   echo $NEWVALUE > /sys/class/backlight/lcd0/brightness
   echo $NEWVALUE
else
   echo $LCDVALUE
fi

try running them with  :

     sudo  -i

     ./lcd_plus.sh

     ./lcd_minus.sh

Now all that has to be done in i3 is to bind them to a keysym  using exec !
Works well.
Shy


Note:  of course,  you could combine them into a single script and pass a parm (up) or (down) 

try it !
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#4


Ok,  expanding on a theme, I have combined the scripts here into one script that takes two parameters;  the first is the direction ( U for up;  D for down ) and the second is the scalar value.


lcd_bright.sh

Code:
#!/bin/bash

MODE=`echo $1 |tr '[a-z]' '[A-Z]'`
LCDVALUE=`cat /sys/class/backlight/lcd0/brightness`

if [ "$MODE" = "U" ]
then
   NEWVALUE=$(( $LCDVALUE + $2 ))
   if [ $NEWVALUE -le 100 ]
   then
       echo $NEWVALUE > /sys/class/backlight/lcd0/brightness
       echo $NEWVALUE
   else
       echo $LCDVALUE
   fi
else
   NEWVALUE=$(( $LCDVALUE - $2 ))
   if [ $NEWVALUE -gt 30 ]
   then
       echo $NEWVALUE > /sys/class/backlight/lcd0/brightness
       echo $NEWVALUE
   else
       echo $LCDVALUE
   fi
fi


Run the script with :

       sudo  -i

       ./lcd_bright.sh  U  10

or

       ./lcd_bright.sh  D  10

Notes:
       The U and D  can be upper or lower case ( the script upper cases it for you ).
       The script might be changed to set a maximum or minimum based on parameter--  try it !

Shy
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#5
Thank you a lot Smile I did bindings and it is working really good!

Even without "sudo -i" after "sudo chown pine64: brightness" command Smile
  Reply
#6
Excellent dude!   Big Grin


I got my bindings to work too, in i3,  with bindsym(s) in  ~/.config/i3/config

... but first I created a group called gpio_pins,  to give permissions to write to the file brightness, and added my pine64 user to the group!

 Also, I added a rule to my sudoers configuration ( use visudo ) similar to this:

# my extra rules
Cmnd_Alias LCDBRIGHT=/usr/local/sbin/lcd_bright.sh
ALL ALL=NOPASSWD: LCDBRIGHT

Then in ~/.config/i3/config  I added a bindsym near the bottom:

bindsym $mod+Shift+u  exec  sudo lcd_bright.sh u 10
bindsym $mod+Shift+d  exec  sudo lcd_bright.sh d 10

Then,  restart i3  with mod+Shift+r

...  now  mod+Shift+u  turns up the brightness,  and  mod+Shift+d  turns down the brightness.

nice
Shy
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
  Reply
#7
Thank you for the great advice @MarkHaysHarris777!
To get this work on my Pinebook (1080p - Arch image with i3) I had to change the file from  /sys/class/backlight/lcd0/brightness to /sys/class/backlight/backlight/brightness, the top value from 100 to 10  and the stepping to single digits. I'm not sure if this is due to the hardware or the os or both.

To get the max possible value: `cat /sys/class/backlight/backlight/max_brightness`

The script to raise the brightness then looks like this:


Code:
#!/bin/bash

LCDVALUE=`cat /sys/class/backlight/backlight/brightness`
NEWVALUE=$(( $LCDVALUE + 1 ))

if [ $NEWVALUE -le 10 ]
then
  echo $NEWVALUE > /sys/class/backlight/backlight/brightness
  echo $NEWVALUE
else
  echo $LCDVALUE
fi

and the one to decrease it (careful - this can completely dim the screen when the value gets to 0):


Code:
#!/bin/bash

LCDVALUE=`cat /sys/class/backlight/backlight/brightness`
NEWVALUE=$(( $LCDVALUE - 1 ))

if [ $NEWVALUE -ge 0 ]
then
  echo $NEWVALUE > /sys/class/backlight/backlight/brightness
  echo $NEWVALUE
else
  echo $LCDVALUE
fi

More info: https://wiki.archlinux.org/index.php/backlight
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Pinebook 1080p / KDE Neon freezes every 5-10 min pyrrhumain 4 100 Yesterday, 07:34 PM
Last Post: pyrrhumain
  will openMP work on a pinebook? rustythorn 2 77 07-23-2019, 01:42 PM
Last Post: tophneal
Information Manjaro ARM for Pinebook erchache2000 61 3,910 07-20-2019, 04:09 AM
Last Post: Luke
  Armbian - Xenial Desktop (Pinebook) pineadmin 83 16,978 07-17-2019, 01:22 PM
Last Post: catsmile
  pinebook 1080p crash and fix nano2 2 162 06-24-2019, 07:41 PM
Last Post: pyrrhumain
  NIxOS installation guide for Pinebook Surehand53 0 127 06-23-2019, 03:46 AM
Last Post: Surehand53
  Improve the life of your Pinebook battery by setting charger's voltage limits wlad 0 130 06-11-2019, 02:27 PM
Last Post: wlad
  Adding coherent_pool to boot.cmd on Xenial Mate by Ayufan causes boot loop k_mp 0 59 06-11-2019, 01:36 PM
Last Post: k_mp
  How can I reliably get battery status on pinebook tillea 5 1,249 06-11-2019, 10:10 AM
Last Post: wlad
  pinebook black screen when booting with "different power mode than last used" penzoiders 9 451 06-06-2019, 02:02 PM
Last Post: Surehand53

Forum Jump:


Users browsing this thread: 1 Guest(s)