How to set Keybindings for LCD Brightness in i3wm
#1
Information 
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
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
#2
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?
  Reply
#3
The FAQ in the Wiki suggests the shell command xbrightness
http://wiki.pine64.org/index.php/1080P_P...n_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
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Information How to set the Power Off key binding in i3wm for the Pinebook MarkHaysHarris777 4 1,145 12-25-2018, 05:57 AM
Last Post: binholz
  How to Configure Screen Brightness in mate on pinebook via terinal? shirman 6 909 12-02-2018, 05:37 AM
Last Post: mikee3000
Information How to manage Wifi in xenial-i3 i3wm image UPDATE MarkHaysHarris777 4 853 09-14-2017, 12:12 AM
Last Post: dahni
Information i3wm xenial-i3 introduction -- mate terminal & battery monitor MarkHaysHarris777 4 1,376 08-31-2017, 04:47 AM
Last Post: shirman

Forum Jump:


Users browsing this thread: 1 Guest(s)