How to set the Power Off key binding in i3wm for the Pinebook
#1
Information 
Greetings,

The purpose of this blog post is to detail the steps necessary to set the Power Off key-binding for the Pinebook in i3 window manager.  We don't want the Pinebook to come crashing down if we accidentally touch the poweroff button -- so we'll set a key-binding that makes sense requiring at least two other keys , for instance the $mod key and the Shift key.  The following key-binding should bring the system down cleanly ( and power off properly ) without prompting for a password:

       $mod+Shift+XF86_PowerOff 

The key-binding will be placed in the i3 config;  but I'm getting ahead of myself.  The first step is to build the poweroff script in /usr/local/sbin/

Pb_poweroff.sh

Code:
#!/bin/sh

poweroff

The simple script above should be placed in  /usr/local/sbin/  and should be made active with the following commands:

       sudo  chown  root:root  Pb_poweroff.sh

       sudo  chmod  0754  Pb_poweroff.sh

The next step is to place a rule file in  /etc/sudoers.d/  so that the command trigger will not prompt for the sudo password when the key-binding is pressed.  Creat the following rule file in /etc/sudoers.d/  :

Pb_power_rule

Code:
# Pb power rule
Cmnd_Alias PBPOWEROFF=/usr/local/sbin/Pb_poweroff.sh
ALL ALL=NOPASSWD: PBPOWEROFF

Place the above rule file in the  /etc/sudoers.d/  directory and activate with the following commands :

       sudo  chown  root:root  Pb_power_rule

       sudo  chmod  0440  Pb_power_rule

The last step is to place the following bindsym entry in the i3 configuration  ~/.config/i3/config  , in your home directory:

       bindsym  $mod+Shift+XF86_PowerOff  exec  sudo  /usr/local/sbin/Pb_poweroff.sh

Place the above bindsym entry somewhere near the end of your i3 config after the "resize"  and before the "bar".  The configuration file is  ~/.config/i3/config

Activate the key-binding by either pressing $mod+Shift+c to re-read the config,  or $mod+Shift+r to restart i3wm.

Theory

Pressing the Pinebook power button returns scancode 124;  key-sym XF86_PowerOff.  This by default does nothing in i3wm;  unlike other OS window manager | desktops  ,  which typically pulls up the shutdown dialogue.

With our keybinding in effect the Pb_poweroff.sh script will be called with sudo,  and because the Pb_power_rule file exists in /etc/sudoers.d/  the command trigger will not prompt for the password,  but the poweroff command will simply take effect:   while holding down the mod key,  and the Shift key together,  press the power button and the i3 window manager will exit and the system will cleanly shutdown and power off.

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! )


Messages In This Thread
How to set the Power Off key binding in i3wm for the Pinebook - by MarkHaysHarris777 - 09-16-2017, 10:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  DietPi OS for Pinebook MichaIng 3 6,937 03-11-2024, 05:02 PM
Last Post: oxoocoffee
  Slarm64 on Pinebook [Slackware Arm - 64 bit] KRT 46 70,874 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)