Tag Archives: screen blanking

Ratpoison and Screen Blanking

We needed a little kiosk style machine for our ‘company’ dashboard and have opted for a little pi running python and midori. And it works like a treat.

# Install Raspbian and the following
$ ssh pi@raspberrypi
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install ratpoison midori

# We also needed for our python web app:
$ sudo apt-get install python python-pip mysql-client libmysqlclient-dev python-dev
$ sudo pip install MySQL-python boto web.py

After that configure your window manager to use ratpoison:

$ sudo update-alternatives --config x-window-manager
There are 2 choices for the alternative x-window-manager (providing /usr/bin/x-window-manager).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/openbox     90        auto mode
  1            /usr/bin/openbox     90        manual mode
* 2            /usr/bin/ratpoison   20        manual mode

Setup your xinitrc file to disable screen saver/dpms and start ratpoison

$ sudo vi ~/.xinitrc
xset s off     # don't activate screensaver
xset -dpms     # disable DPMS (Energy Star) features.
xset s noblank # don't blank the video device
exec /etc/alternatives/x-window-manager

Setup the pi to ‘auto login’

# Edit inittab comment and add the following new line
$ sudo vi /etc/inittab
#1:2345:respawn:/sbin/getty --noclear 38400 tty1 
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Setup startx on login
(todo: probably could do this via debian x-session-manager/lightdm conf)

$ vi ~/.bash_profile 
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
    startx
fi

To confirm Screen saver settings run the following

$ export DISPLAY=:0.0
$ xset q
Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  660    repeat rate:  25
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  no    allow exposures:  yes
  timeout:  0    cycle:  600
Colors:
  default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffff
Font Path:
  /usr/share/fonts/X11/Type1,built-ins
DPMS (Energy Star):
  Standby: 600    Suspend: 600    Off: 600
  DPMS is Disabled

Using rc.local to start our python script and turn off terminal blanking
(todo: probably could just launch our python app using init.d script… meh)

$ sudo vi /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

#Starts the python dashboard
/home/pi/dashboard/simplePython/startdash.sh &

setterm -blank 0

exit 0