如何安裝樹莓派虛擬鍵盤

1. 安裝所需軟體matchbox-keyboard

sudo apt update
sudo apt install matchbox-keyboard

2. 開啟編輯toggle-matchbox-keyboard.sh腳本

sudo nano /usr/bin/toggle-matchbox-keyboard.sh

3. 複製以下內容至toggle-matchbox-keyboard.sh腳本,存檔後退出

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

4. 新增執行權限

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

5. 開啟編輯toggle-matchbox-keyboard.desktop桌面捷徑

sudo mkdir /usr/local/share/applications
sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop

6. 複製以下内容至toggle-matchbox-keyboard.desktop,存檔後退出

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

7. 使用”pi”用戶權限開啟編輯panel文件,注意此處不可以用管理員權限執行,否則會找不到檔案

sudo nano /etc/xdg/lxpanel/LXDE-pi/panels/panel

8. 在panel文件中找到類似以下區塊,注意不同版本圖示可能會有些微差異

Plugin {
type = launchbar
Config {
Button {
id=lxde-screenlock.desktop
}
Button {
id=lxde-logout.desktop
}
}

9. 新增以下內容至Button區塊,以新增虛擬鍵盤按鍵

Button {
id=/usr/local/share/applications/toggle-matchbox-keyboard.desktop
}

10. 完成後檔案內容大致如下,存檔後退出

RPILCD-INSTALL-KEYBOARD01.png

11. 重開機後應該可以看到螢幕左上角多了1個虛擬鍵盤圖示

sudo reboot