Site icon miniLiew

Raspberry Pi – Installing On Screen Keyboard

Date:  Jun 8, 2016

I bought the official 7″ Touch Screen display for my Raspberry Pi 3.

Instead of using a USB dongle to connect to a keyboard, it is very useful to install a on screen keyboard.  Whenever you need it, you will want to use it, very handy.

The popular on screen keyboard program is called matchbox-keyboard

Installation

$ sudo apt-get update

$ sudo apt-get upgrade -y

$ sudo apt-get install matchbox-keyboard -y

$ sudo reboot

After reboot, the installation program failed to install it onto your “Accessories” due to you might have a newer Raspbian, and the apt-get install matchbox-keyboard works in the older Raspbian LXDE.

Not to worry, follow the following steps will put that into the Start Menu, and on the task bar too.

Creating a matchbox-keyboard Script

$ sudo vi matchbox-keyboard.sh         (or you can use nano instead of vi)

key in the following …

#!/bin/bash
# kenliew - this is a simple script to run the virtual on screen keyboard

PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
  killall matchbox-keyboard
else
 matchbox-keyboard&
fi

Make the script executable.

$ sudo chmod +x /usr/bin/matchbox-keyboard.sh

Add it to the Start Menu

$ cd /usr/share/applications

$ vi matchbox-keyboard.desktop

Edit the file, by adding this into the matchbox-keyboard.desktop file

[Desktop Entry]
Name=Matchbox Keyboard
Comment=Run Matchbox Keyboard
Exec=matchbox-keyboard.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANISM=True

 

Add it to the Task Bar

All LXDE configurations are stored under .config directory under your “pi” acct.  Edit the file /home/pi/.config./lxpanel/LXDE-pi/panels/panel

$ cd .config

$ cd lxpanel

$ cd LXDE-pi

$ cd panels

$ vi panel

I think let’s place the keyboard icon in between the Bluetooth icon and the Tray.

Place the following codes in between them.  Add a space behind too.

Plugin {
    type = launchbar
    Config {
        Button {
            id=matchbox-keyboard.desktop
        }
    }

Plugin {
    type = space
    Config {
        Size=2
    }
}

$ /usr/bin/lxpanelctl restart

And you can see that small little keyboard there.

And here comes the keyboard.

And the main menu is working too.

The reason why we created the .sh file is to kill existing process before launching a new matchbox-keyboard process.  That will prevent us from running multiple copies of the process.

 

 

Exit mobile version