Toggle Matchbox Keyboard

I added a “launchbar” icon in the taskbar, to act as a toggle switch, so touching the icon started matchbox and touching it again closed matchbox. That seems to be what you’re looking for.

Looking at my notes this is what I did, and it should still work since matchbox-keyboard hasn’t been updated in a long time.

All the keyboard layouts provided in the install are located at /usr/share/matchbox-keyboard. You’ll see a list of .xml files, choose the one closest to what you need, the file names are somewhat descriptive. The .xml file you choose can also be edited to customize the characters, spacing, size, key location, etc. for the keyboard. If you copy that file of choice to your home directory that is the keyboard file it will use, you won’t have to specify a layout when starting matchbox-keyboard, and you can edit that user file and leave the original .xml files unchanged in case you need to back up or start over.

First create a .matchbox directory

mkdir ~/.matchbox

Then copy your .xml file of choice to that directory, in this example I used the US keyboard

cp /usr/share/matchbox-keyboard/keyboard-us.xml ~/.matchbox/keyboard.xml

After that all your .xml keyboard edits will be done in ~/.matchbox/keyboard.xml

nano ~/.matchbox/keyboard.xml

Now that you have a default keyboard file in place to make startup and editing easier you’ll need to create a bash script that will either toggle the keyboard on or off each time the script is run. I use a “scripts” directory to hold all my bash scripts, but you can put it wherever you like.

nano ~/toggle-matchbox.sh

#!/bin/bash
#This script toggles the virtual keyboard on or off
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard &
fi

Don’t forget to make it executable.

Now you’ll need to create a desktop file, this will add it to the menu, and allow you to add it to the launchbar so you can start/stop the keyboard with a single touch of the icon in the taskbar. Edit the path to your “toggle” shell script as needed.

sudo nano /usr/share/raspi-ui-overrides/applications/toggle-matchbox.desktop

[Desktop Entry]
Name=Toggle Matchbox Keyboard
Comment=Toggle Matchbox Keyboard
Exec=/home/pi/toggle-matchbox.sh
Type=Application
Icon=matchbox-keyboard.png
Categories=Panel;Utility;MB
X-MB-INPUT-MECHANSIM=True

Now you need to add it to the “Launchbar” for a one touch start/stop. You can use the Desktop GUI to add a button to the launchbar, but sometimes the Pi doesn’t update the menu in a timely manner after you’ve made changes, and you can’t add it to the launchbar until it shows up in the menu if you’re using the GUI. So I just went ahead and added the “toggle matchbox” button manually.

I did that by adding an entry to the launchbar plugin, so open the lxpanel file for editing

nano ~/.config/lxpanel-pi/LXDE/panels/panel

Scroll down the file till you see the section for the launchbar plugin. You can see I currently have 4 buttons in the launchbar

Plugin {
type=launchbar
Config {
Button {
id=/usr/share/raspi-ui-overrides/applications/pcmanfm.desktop
}
Button {
id=/usr/share/raspi-ui-overrides/applications/lxterminal.desktop
}
Button {
id=/usr/share/applications/iceweasel.desktop
}
Button {
id=/usr/share/raspi-ui-overrides/applications/galculator.desktop
}
}
}

Add the new button entry to the launchbar plugin. I added mine to the top of the “button” list so it would show up next to the “Menu” button. If you want the toggle button to appear to the right add it at the bottom of the list, or even somewhere in the middle of the list.
This is what the file looked like after adding the button.

Plugin {
type=launchbar
Config {
Button {
id=/usr/share/raspi-ui-overrides/applications/toggle-matchbox.desktop
}
Button {
id=/usr/share/raspi-ui-overrides/applications/pcmanfm.desktop
}
Button {
id=/usr/share/raspi-ui-overrides/applications/lxterminal.desktop
}
Button {
id=/usr/share/applications/iceweasel.desktop
}
Button {
id=/usr/share/raspi-ui-overrides/applications/galculator.desktop
}
}
}

Now restart lxpanel and you should see the new “button” in the launchbar. Touch it to open the keyboard, touch it again to close.

lxpanelctl restart

As I said in the beginning I’m using notes and my memory for this since I’m not currently using matchbox-keyboard. But everything appears to be correct, and I usually keep good notes when adding things, so it should work fine. Maybe it will help you out in finding a solution.

Source: https://www.raspberrypi.org/forums/viewtopic.php?t=112515

Calibrate Waveshare 5″ Resistive Touchscreen

# install calibrator and evdev (allows multiple keyboards mice treated as separate device)
sudo apt install xinput-calibrator xserver-xorg-input-evdev

# make evdev higher number than libinput
sudo mv /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf

# list devices
xinput

# view calibration option
xinput --list-props <deviceid>

# calibrate
xinput_calibrator

# copy paste the result like below to /usr/share/X11/xorg.conf.d/99-calibration.conf:
Section "InputClass"
Identifier "calibration"
MatchProduct "BYZHYYZHY By ZH851"
Option "Calibration" "182 3859 277 3944"
Option "SwapAxes" "0"
EndSection

Source: https://www.waveshare.com/wiki/5inch_HDMI_LCD_(B)