TiM next to BGA

Demonstrating and building the simple TiM Screen information / image viewer (Version 1)

Here’s one before we added the rotary encoder and motion sensor modules.

Strategically positioned next to the blood gas analyser capturing the attention of staff whilst they process samples. Specifically setup on a 19″ monitor in portrait orientation displaying a selection of ‘Watch Out’ notices containing useful clinical information.

We have placed a couple of the Watch Out TiM’s around the department whilst a wall mounted 40″ screen in the waiting room displays relaxing pictures and useful information for visitors to view.



1 Getting Ready with the OS (Linux Operating System)
2 Some admin tasks
3 Install the picture viewer (pqiv)-V1
4 Create the picture viewer shell script
5 Samba – file share setup
6 Launch the pqiv script file when the GUI opens
7 Autologon with the Tim account
8 Prevent screen blanking/powersave!
9 Screen orientation (if required)
10 Black border?
11 Copying images to your TiM file share
12 Some Security Considerations
13 Troubleshooting


Currently, version 1 provides simple picture frame features for displaying a random collection of images stored on it’s micro SD Card. Image files are updated from another computer on the same network subnet by accessing the password protected ‘Samba‘ share or via SFTP if you prefer. Alternatively, files could easily be stored on a usb drive. An effective way to create information slides is to use something like Powerpoint where you can design a template, apply your information and then save all slides as images. The maximum RPi resolution is Full HD (1920 * 1080) and this can be customised in Powerpoint by setting the page size to 50.8cm * 28.575cm. Alternatively, TiM will resize images to their best fit whilst maintaining the aspect ratio.

1 Getting Ready with the OS (Linux Operating System)

I use the Raspberry Pi ‘raspbian‘ OS (currently Jessie Pixel “Pi Improved Xwindows Environment Lightweight” – as of March 2017). Please note that the ‘Lite’ version does not come with a Graphical User Interface and would not be suitable for this example without installing a GUI separately.

If you don’t have a working RPi OS ready to go, then take a look at the Raspberry Pi’s official documentation for setting one up https://www.raspberrypi.org/help/noobs-setup/

One quick note about upgrades: Following a recent OS upgrade to Jessie, I experienced a head scratching moment where the graphical desktop appeared to crash on a black screen. This was quite frustrating after performing all the usual updates and as it transpired, my RPi required a firmware update. After entering sudo rpi-update and some impatient tapping, the system was up-to-date. Another attempt at installing the Jessie image and voila! I would only perform this action as a last resort incase of power loss or network failure during an upgrade which could brick the RPi.

2 Some admin tasks


When getting started, your Pi will usually start up with a familiar looking user friendly desktop environment where some of our admin tasks can be performed. With the first point of security, it’s good practice to change the default ‘pi’ password.

This can be achieved in a few of ways:

1) For simplicity navigate to the Pi Menu from the top left corner of the screen, click Preferences from the drop down list and select Raspberry Pi Configuration. The first option under the “System Tab” includes a button called “Change Password…”

2) Alternatively, you could open a command line\shell and enter the following command where you will be prompted to enter a new password:


3) You could also use the raspi-config tool from the command line – enter:

sudo raspi-config <sudo runs commands as the Superuser (SUperuser DO)>

..and select change password from the menu. Further information can be found here.

Boot Options

Throughout some of our configuration, we need TiM to boot directly to the command prompt console. If not booting to the console already then use the Raspberry Pi Configuration to select CLI or using the raspi-config tool to select Console under the Boot Options menu.


For the purpose of accessing your TiM(s) file share accross the network, it’s important to know the hostname. You could leave this as ‘raspberrypi’ or change it to something descriptive relating to the location such as FrontRoom or a meaningful abbreviation OPWR1! It’s easy to change the hostname with the Raspberry Pi Configuration feature that we opened earlier or the via the raspi-config tool.

Please note: If you plan on having more than one TiM on the same network, you will need to use unique hostnames to avoid any network conflicts.

Memory split for GPU

With TiM spending time displaying images, for stability, I have set the graphics processing unit (GPU) to use 256MB of memory. To change this, use the Raspberry Pi Configuration/Performance or again via the raspi-config tool under Advanced Options and Memory Split.

Staying up-to-date

You will need to run two commands to ensure that you have the most up-to-date packages. Be prepared to find something else to do whilst your RPi looks busy because this may take an hour or two..

Enter this command to synchronise the database with available software packages and versions. This shouldn’t take too long…

sudo apt-get update

Next, upgrade the packages with the newer versions

sudo apt-get upgrade

Create user account (tim)

Create a basic user account that will soon be used to automatically log on, start the picture viewer and display images from the file share (Step 12 includes an alternative way to add new users and groups at the same time):

sudo adduser tim
password: TimPassword

Add the new tim account to the audio and video groups (minimal groups required for the GUI to work).

sudo adduser tim audio
sudo adduser tim video

3 Install the picture viewer (pqiv) – Version 1

Instead of writing our own picture viewer from scratch, I discovered ‘pqiv’ which has been reliably displaying images for TiM since 2014. This includes a slide show and shuffle feature which is perfect for our requirements. Other picture viewers are available (feh, fbi) but pqiv seemed the most reliable and easiest to use. Version 0.12 which I used previously contained a glitch that I understand resulted in a memory leak. Fortunately I have been using Version 1 since 2014 without any problems and detail how to download the stable version below.

Firstly, remove pqiv if it is already installed..

sudo apt-get remove pqiv

Install the required packages to get the source from ‘git’ and compile it:

if you’re interested in coding, see GitHub for information on code management

sudo apt-get install git libgtk2.0-dev

As user pi in the user home directory (/home/pi), this will create a sub directory ‘pqiv’:

cd /home/pi <Change Directory)
git clone https://github.com/phillipberndt/pqiv.git -b 1.0

Configure will validate all preconditions and create a platform specific make file

cd pqiv
sudo ./configure

Make and install the app

sudo make all install

That’s it, you have installed version 1 of pqiv!

4 Create the picture viewer shell script

Here we will create a simple script to call pqiv with the relevant ‘switches or options’. If you are logged on as user pi, either restart and logon as user tim or switch user using the ‘su’ command:

sudo reboot
or explore the shutdown command
sudo shutdown -r ti now <shutdown and -(r)estart -(ti)me now>

or instead of restarting..

su tim <switch user to tim>

Next, create a folder and file to store the script:

cd /home/tim/ <if you've used 'su' you may not be in the tim home directory>
mkdir bin <folder to keep our script - this can be anything you like>
cd bin <change directory to bin>
nano start-pqiv.sh <start the nano editor and create a new file>

Nano is a ‘friendly’ or easy to use editor which you may prefer compared to the ‘vi’ editor. But if you feel adventurous then take at look at vi which is a classic old school scripting editor that contains many features!

Enter the script contents used to eventually start the picture viewer:

pqiv -i -s -f -t -n -n -d30 ~/frame/pics/ 
# -i(remove border) -s(auto start slide show) -f(full screen) 
# -t(stretch image to fit screen - maintain aspect ratio)
# -n(shuffle) <single -n for sort> -d(slide duration in seconds)
Please note: The hash (#) symbol is used to insert helpful comments into our script files

Press CTRL and X to save and exit nano

Tilde or (~) seen above represents the user home directory (/home/tim). Typing cd ~ or cd $HOME would take you to the home directory for the logged on user.

Make the new shell script file executable:

chmod +x start-pqiv.sh

You may have noticed the path above relates to ~/frame/pics which we need to create to store the images for the pqiv slideshow.

mkdir -p ~/frame/pics <-p saves time for creating a series of folders /frame/pics>

if you are curious about any commands such as mkdir, it’s simple to access the ‘man’ pages by typing man mkdir from a command shell/terminal window.

5 Samba – file share setup

Installing Samba and the image file share is straight forward but we need to switch back to the Pi account first using one of the methods described earlier (if you previously switched user ‘su’ then simply type exit to return to the Pi user!):

sudo apt-get install samba samba-common-bin

Configuring the share requires some modifications to the smb.conf file:

sudo nano /etc/samba/smb.conf

Make the following changes within the smb.conf file

If you have a ‘network workgroup name’ that you would like TiM to appear under then within smb.conf, update the ‘WORKGROUP=’ with your workgroup name.

wins support = yes 
appears under Global Settings near top

Add this section to the bottom of the file (after the section called Share Definitions)

       comment = TiM Screen Image Share
       path = /home/tim/frame/pics
       browseable = yes
       writeable = yes
       only guest = no
       create mask = 0777
       directory mask = 0777
       public = no

Save the changes and restart the Samba daemon

sudo /etc/init.d/samba restart

Next, add the newly created tim account and ‘new’ password to the samba file share to access over the network:

Sudo smbpasswd -a tim
Enter your password choice

When accessing the share from Windows, you can either browse your network for the new share or at the Start Menu run field, type your ‘RPi hostname\TIMPics’ as defined in the smb.conf file.
And when prompted, enter the password set above. Eg


6 Launch the pqiv script file when the GUI opens

When the GUI (X Windows) opens, the following file will automatically launch the script created earlier and begin displaying images.

Please note, if the following folders do not exist you may need to 1) launch the GUI by typing startx and then restart or simply create the folders using mkdir.

Assuming that these folders do not exist, with the tim account logged on enter:

mkdir ~/.config/autostart <create folder structure>
cd ~/.config/autostart
nano pqiv.desktop <launch nano and edit/create the script autostart details>

Enter the follwing contents using nano into the pqiv.desktop file:

[Desktop Entry]

Press CTRL and X to save and exit nano.

7 Autologon with the tim account

For security reasons, we would prefer to avoid automatically logging on with our Pi account which has full admin access. Instead, we’ll use the tim account with restricted access. This needs to automatically log into the console when the RPi starts up and launch ‘startx’ (the windows X GUI) which is easily achieved by updating a couple of files

Console autologon

As user ‘pi’, navigate to the following location (you may need to create the folder structure if it does not exist – using “sudo mkdir -p /etc/systemd/system/getty@tty1.service.d”):

cd /etc/systemd/system/getty@tty1.service.d

Create the auto-login script

sudo nano autologin.conf

And enter the following (exactly as it appears!)

ExecStart=-/sbin/agetty --autologin tim --noclear %I 38400 Linux

Save and exit.

X Windows GUI autologon

The first part of logging in has been taken care of above and now we need to log into the GUI

Edit the following file:

sudo nano /etc/lightdm/lightdm.conf

Now look for the section starting with [SeatDefaults]

Modify the line “autologin-user=pi” to reflect:


You may need to remove the hash #

8 Prevent screen blanking/powersave!

Some power-save/eco features are useful unless they blank the screen during a slide show! Make the following changes to prevent the usual timeout.

Using the ‘pi’ account again: (Linux is case sensitive so it’s important to type exactly as seen with the correct upper/lowercase letters)

sudo nano /etc/X11/xinit/xserverrc

The file will probably look similiar to the one below. Make the changes highlited in blue and then save/exit.

exec /usr/bin/X -s 0 dpms -nolisten tcp "$@"

With earlier builds, the screen blanking options was also set elsewhere. If the above fails to work, take a look at the troubleshooting section 13.

9 Screen orientation (if required)

In the picture of TiM at the top of this page, you will notice the monitor has been rotated to portrait which works well for the documentation displayed. By adding a setting to the config.txt file, the display orientation can be altered as required:

sudo nano /boot/config.txt

Add the following line somewhere – if it does not already exist. It may be #commented out, in which case, remove the hash.


For reference, the orientation is translated as follows:

1= 90 degrees

2=180 degrees

3=270 degrees

10 Black border?

If your display contains a black border encroaching on the full display potential then the overscan may have been enabled. Check out the config.txt file and uncomment disable_overscan:

sudo nano /boot/config.txt
 uncomment #disable_overscan=1 (Remove the #)

Comment out the following (add the #):

#overscan_left=xx (where xx = a number value already set)

11 Copying images to your TiM file share

Hopefully, at this point, after a restart, your Raspberry Pi will automatically log you into the desktop under the tim account!

The picture viewer will not start until we copy some images across. Copy your pics to the file share setup earlier. For example, from another computer on your network browse to:

<RPi hostname>\TIMPics eg. \\FrontRoom\TIMPics

If all has worked as expected, you should be prompted for a username and password. Depending if your RPi is on a windows domain, you may need to prefix the username with the hostname. ie. Username:FrontRoom\tim. The password expected will be the one setup during the Samba configuration at the end of Step 5.

With your tim user authenticated, you should be able to drag and drop pictures to and from the file share.

One minor drawback is that this version of pqiv does not refresh it’s list of images so TiM will need to be restarted to display any changes. This can be done ‘ungracefully’ via the power switch, by hitting CTRL + C and ending (if you have a keyboard connected), through a remote shutdown command or with the addition of a power switch connected to the GPIO pins triggering an event to gracefully shutdown\restart the RPi (details on this to follow).

12 Some Security Considerations

Create a new superuser account

If you’re concerned about your pi username being hacked, you can dissable it and create a new superuser account:

Under the pi login, add a new user to the required superuser groups:

sudo useradd -G sudo, adm mypiadmin <Create 'mypiadmin', add to sudo & adm groups>

When you are prompted for a password (check incase this is the password required for pi – using sudo).

sudo passwd mypiadmin <setup a new password for mypiadmin>

You can check check that your new user has been added to the groups with:

groups mypiadmin
id mypiadmin

Dissable the default pi user account

Log on with your newly created superuser account and remove the pi sudo access using ‘visudo‘ by adding the #hash as seen below:

sudo visudo
#pi ALL=(ALL) NOPASSWD: ALL <Add the hash# to this line

Lock pi account and prevent access via another authentication token (e.g. an SSH key)

sudo usermod -L -e 1 pi <-(L)ock pi account and set (-e)xpiredate to 02/01/1970)

Confirm the lock with:

sudo grep pi /etc/shadow

Notice the ! after username

13 Troubleshooting

Screen blanking issues

If Step 8 has not prevented the screen blanking, there are a couple of other places that you could try altering which have worked for earlier versions of the OS.

sudo nano /boot/config.txt
POWERDOWN_TIME = 0 <This may be #hashed out or not exist>
BLANK_TIME = 0 <This may be #hashed out or not exist>

Also check the powerdown_time and blank_time in the following file:

sudo nano /etc/kbd/config

Auto-logon failing

With earlier versions of Raspbian (pre PIXEL) the following file required modification to achieve autologon:

As user ‘pi’, open the rc.local file:

sudo nano /etc/rc.local

Near the bottom of the file, before ‘exit 0’, enter the details below and then save/exit:

su -l tim -c startx <-l represents the login name, -c startx will start x windows>
x Logo: Shield
This Site Is Protected By