Full Version: How to set Keybindings for LCD Brightness in i3wm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

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/ , 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 ( which does the work ) and the second one is the source file for /etc/sudoers.d which allows the bindsym to call without a password.

# v0.1a
# Mark H. Harris
# 08/31/2017
# Usage: <U|D> <value>

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

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


# lcd bright rules
Cmnd_Alias LCDBRIGHT=/usr/local/sbin/


Open a terminal and access root with :

       sudo  -i

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

Set the owner and group with :

       cd  /usr/local/sbin/

       chown  root

       chgrp  root

Make the script executable with :

       chmod  0754

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  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.


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 :

bindsym $mod+Shift+u exec sudo /usr/local/sbin/ u 10
bindsym $mod+Shift+d exec sudo /usr/local/sbin/ 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)

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?
The FAQ in the Wiki suggests the shell command xbrightness

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