[Feb 26] Recalbox beta v3.1- Rock64 |[Feb 26] Recalbox 190222- RockPro64 / Minimal Debian by mrfixit2001 - 190222 - RockPro64 |[Feb 26] Q4OS 2.7-r2 - Pinebook 1080P / Pinebook |[Feb 22] Batocera Linux 5.20-20190121- RockPro64 | [Feb 19] Manjaro KDE 19.02 / Manjaro LXQT 19.02 - Pinebook1080P / Pinebook | [Feb 19] Slackware Aarch64 Miniroot and XFCE 20190201 - RockPro | [Feb 19] Slackware Aarch64 Miniroot and XFCE 20190201 - Rock64

Project Inspiration | Get Started | IRC Logs | Forum Rules/Policy


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 27 273 2 hours ago
Last Post: soupbowl
  Problems putting Ubuntu (Xenial Mate) on my replacement eMMC. frank-zappa 0 50 03-18-2019, 05:50 PM
Last Post: frank-zappa
  Armbian - Xenial Desktop (Pinebook) pineadmin 79 13,503 03-06-2019, 04:20 PM
Last Post: tllim
  How can I reliably get battery status on pinebook tillea 4 906 03-05-2019, 06:43 AM
Last Post: chessie
  Q4OS for PINEBOOK q4osteam 84 19,814 02-26-2019, 01:39 AM
Last Post: pineadmin
  Archlinux (mainline) for Pinebook anarsoul 48 11,148 02-15-2019, 02:19 PM
Last Post: e-minguez
  No display options on Pinebook or Pineboard Fox7799 0 146 02-06-2019, 11:56 AM
Last Post: Fox7799
  KDE Neon Pinebook remix edition RC image bshah 64 17,303 02-06-2019, 06:04 AM
Last Post: soupbowl
  Exagear Desktop on Pinebook AndyK 2 1,190 01-18-2019, 04:20 AM
Last Post: binholz
  DietPi for Pinebook Fourdee 10 2,081 01-09-2019, 08:38 AM
Last Post: WZ9V

Forum Jump:


Users browsing this thread: 1 Guest(s)