PINE64
How to set Keybindings for LCD Brightness in i3wm - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook (https://forum.pine64.org/forumdisplay.php?fid=76)
+--- Forum: Linux on Pinebook (https://forum.pine64.org/forumdisplay.php?fid=79)
+--- Thread: How to set Keybindings for LCD Brightness in i3wm (/showthread.php?tid=5068)



How to set Keybindings for LCD Brightness in i3wm - MarkHaysHarris777 - 09-01-2017

Greetings,

The purpose of this tutorial blog post is to describe how to setup LCD brightness keybindings in the i3wm tiling window manager , on your Pinebook.

Below I am providing a script which will be placed in /usr/local/sbin/lcd_bright.sh , which may be used to set the brightness of the LCD display in increments of +10 or -10.  I will describe the step(s) necessary to activate the script via /etc/sudoers.d so that the keybindings ( bindsym ) in the i3 config can run as sudo without needing to prompt for the password !

First, the scripts... the first one is the lcd_bright.sh ( which does the work ) and the second one is the source file for /etc/sudoers.d which allows the bindsym to call lcd_bright.sh without a password. 

lcd_bright.sh

Code:
#!/bin/bash
#
# lcd_bright.sh v0.1a
#
# Mark H. Harris
# 08/31/2017
#
# Usage:  lcd_bright.sh <U|D> <value>
#

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

lcd_bright_rules

Code:
# lcd bright rules
Cmnd_Alias LCDBRIGHT=/usr/local/sbin/lcd_bright.sh
ALL ALL=NOPASSWD: LCDBRIGHT

Procedure:

Open a terminal and access root with :

       sudo  -i

Place the  lcd_bright.sh  script in the  /usr/local/sbin/  directory.

Set the owner and group with :

       cd  /usr/local/sbin/

       chown  root  lcd_bright.sh

       chgrp  root  lcd_bright.sh

Make the script executable with :

       chmod  0754  lcd_bright.sh

Place the  lcd_bright_rules  file in the  /etc/sudoers.d/  directory.

Set the owner and group with :

       cd  /etc/sudoers.d

       chown  root  lcd_bright_rules

       chgrp  root  lcd_bright_rules

Set special read permissions with :

       chmod  0440  lcd_bright_rules



At this point the system is setup to use the  lcd_bright.sh  script.  The last step(s) necessary is to set the keybindings in the i3wm config file.

You do not need root permissions to do the following;  if you're still in root#  please exit.

       exit

Change into the i3wm config directory for your default  pine64  i3 user with :

       cd  ~/.config/i3/

Use your favorite editor to edit the  config  file.

Somewhere near the end of the other bindsym entries ,  add these two definitions :


Code:
bindsym $mod+Shift+u exec sudo /usr/local/sbin/lcd_bright.sh u 10
bindsym $mod+Shift+d exec sudo /usr/local/sbin/lcd_bright.sh d 10


Save the file.

Re-read the config file with :

       mod + Shift + c

Restart the i3wm tiling window manager with :

       mod + Shift + r

Congratulations!  Your brightness keybindings are set for i3wm.

To use the keybindings use :

       mod + Shift + u        (turns up the LCD backlight by 10)

       mod + Shift + d        (turns down the LCD backlight by 10)

Shy


RE: How to set Keybindings for LCD Brightness in i3wm - alduplat - 12-09-2018

Hi There,

Thank you for your help. I have a Pinebook 1080P running i3 on top of KDE Neon. I have applied several of your tips.
I followed the instructions step by step but they are not working.

I wonder if anybody has ideas on how to control LCD brightness on i3 in a Pinebook 10180p?


RE: How to set Keybindings for LCD Brightness in i3wm - Surehand53 - 12-09-2018

The FAQ in the Wiki suggests the shell command xbrightness
http://wiki.pine64.org/index.php/1080P_Pinebook_Main_Page#FAQ

However with Manjaro this seems not to work but I think I remember that with the KDE Neon image it worked. You can just try