Thursday, August 8, 2013

On Screen Keyboard for Raspberry Pi

I faced a little difficulty with the limited number of USB ports available on Raspberry Pi. I wanted to test a USB bluetooth adapter on a Raspberry Pi and obviously I wanted the keyboard and mouse connected to it at the same time. So, I needed 3 USB ports but there are only 2 ports available. One option was to use a USB hub. However when using a USB hub, it seemed my bluetooth adapter is not working as expected which I guess due to low amount of current it can drag through the USB hub. Anyway, I had to look for a solution and there is a simple solution.

I searched in the web for a on-screen keyboard for Raspberry Pi and found this thread. I tried it and worked fine. I'm writing down it here in case I need to do such a thing again oneday. I installed the on-screen keyboard program by issuing the following command in the terminal.

sudo apt-get install matchbox-keyboard

After it completed the installation, we can start it by typing the following in the terminal. The reason is, there is no any launcher icon coming to the desktop or anywhere. Therefore we have to launch it from the command line.

sudo matchbox-keyboard

However its obvious that we cannot have a hardware keyboard to type that command in the terminal in each time we need a keyboard. So, we need a launcher icon. So, we have to add a desktop shortcut for launching the on-screen keyboard. For that, as instructed in that thread, I created a file in the desktop and named it keyboard.sh (name can be anything). In the file I added the following.

#!/bin/bash
matchbox-keyboard

When we double click it, this shell script should run. For that we have to set the executable permission for this file. So, from the terminal, I went to the desktop where this file is saved and issued the following command.

chmod +x keyboard.sh

 Now, when we double click on the file in the desktop, a pop up message should come asking what to do. One option should be to run the file as an executable. By selecting that option, our on-screen keyboard should launch.

5 comments:

  1. When i type chmod command it shows
    Key.sh which i already saved in desktop lx terminal says

    Chmod: cannot access 'key.sh' : no such file or directory
    I use rasbian os and rpi vB

    Plz help

    ReplyDelete
    Replies
    1. ensure your in the right directory (desktop) with dir (to see if file is there) and cd (to go to directory)
      if wont work, idk

      Delete