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
Information Manjaro ARM for Pinebook erchache2000 40 1,583 05-24-2019, 04:49 AM
Last Post: trigger
  pinebook black screen when booting with "different power mode than last used" penzoiders 7 225 05-20-2019, 02:46 AM
Last Post: penzoiders
  Wifi I/F on Pinebook 11.6" eblot 2 251 05-19-2019, 04:53 PM
Last Post: Shoananas
  KDE Neon Pinebook remix edition RC image bshah 67 19,042 05-18-2019, 11:44 AM
Last Post: rookieone
  Blank Screen on Boot MECZero 4 186 05-12-2019, 11:54 AM
Last Post: tllim
  Problems putting Ubuntu (Xenial Mate) on my replacement eMMC. frank-zappa 11 340 05-01-2019, 12:09 PM
Last Post: frank-zappa
  Q4OS for PINEBOOK q4osteam 86 22,731 04-23-2019, 02:09 AM
Last Post: pineadmin
  Netrunner 18.03 Idolon for the Pinebook shadeslayer 92 11,926 04-21-2019, 11:37 AM
Last Post: cuvtixo
  Armbian - Xenial Desktop (Pinebook) pineadmin 79 14,584 03-06-2019, 04:20 PM
Last Post: tllim
  How can I reliably get battery status on pinebook tillea 4 1,032 03-05-2019, 06:43 AM
Last Post: chessie

Forum Jump:


Users browsing this thread: 1 Guest(s)