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:
pine64@pinebook:~$ 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:
pine64@pinebook:~$ sudo xrandr --output default --brightness 0.5

It isn't do anything. 

Code:
pine64@pinebook:~$ echo 240 > /sys/class/backlight/lcd0/brightness


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

Code:
root@pinebook:/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
#3
(08-31-2017, 12:28 PM)shirman Wrote: I found this, but it is not working with sudo, only after sudo su

Code:
root@pinebook:/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! )
#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! )
#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
#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! )
#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


Possibly Related Threads…
Thread Author Replies Views Last Post
  DietPi OS for Pinebook MichaIng 3 6,935 03-11-2024, 05:02 PM
Last Post: oxoocoffee
  Slarm64 on Pinebook [Slackware Arm - 64 bit] KRT 46 70,753 09-26-2023, 03:18 PM
Last Post: mara
  Broke pinebook GUI, what to do, fix or install new? acruhl 2 1,546 07-13-2023, 05:43 PM
Last Post: acruhl
  Orignal PineBook jwp1000 1 1,164 07-10-2023, 07:44 AM
Last Post: tophneal
  Pinebook no longer boots rjtanner 12 5,653 04-13-2023, 01:09 PM
Last Post: tophneal
  Stock Debian on original Pinebook moonwalkers 1 3,750 01-29-2022, 10:37 PM
Last Post: cel
  Write image to eMMC - Pinebook 11.6" irongarment 4 4,700 01-04-2022, 09:22 PM
Last Post: irongarment
  E: The repository 'http://pinebook.kde.org.uk bionic Release' no longer has a Release pixelpaperyarn 3 5,918 05-07-2021, 10:20 AM
Last Post: tophneal
  pinebook.kde.org.uk no longer has release file?? supermassive 1 4,217 01-20-2021, 11:18 AM
Last Post: tophneal
Question Ran apt update on my Pinebook.. ford442 0 3,128 12-25-2020, 04:40 PM
Last Post: ford442

Forum Jump:


Users browsing this thread: 1 Guest(s)