如何在Yocto构建的Allwinner A20 Cubieboard2登录时启动虚拟键盘
Great question! Since you’ve got core-image-sato up and running with LXDm on your Cubieboard 2, getting that virtual keyboard to auto-launch at the graphical login screen is straightforward. Let’s break this down step by step:
1. First, confirm your virtual keyboard is installed
Core-image-sato usually includes matchbox-keyboard (a lightweight, perfect fit for embedded touch setups), but if it’s missing, add it to your Yocto build by editing conf/local.conf:
IMAGE_INSTALL:append = " matchbox-keyboard"
Rebuild your image, or use devtool to install it directly on your running system if you’re testing quickly.
2. Configure LXDm to launch the keyboard at login
LXDm’s greeter (the login screen interface) has a few ways to auto-start applications. Pick whichever fits your workflow:
Method 1: Edit LXDm’s main config
Open /etc/lxdm/lxdm.conf and find the [base] section. Add this line to trigger the keyboard when the greeter loads:
greeter-setup-script=/usr/bin/matchbox-keyboard &
The & ensures the keyboard runs in the background so the login screen doesn’t hang. If you need to tweak the keyboard’s position or size (to fit your touchscreen), add parameters like -x 0 -y 400 -s 60 to set X/Y coordinates and key size.
Method 2: Add an autostart desktop file
Create a .desktop file in LXDm’s global autostart directory. Make /usr/share/lxdm/autostart/matchbox-keyboard.desktop with this content:
[Desktop Entry] Name=Virtual Touch Keyboard Comment=Launches matchbox keyboard for touch input Exec=matchbox-keyboard Type=Application X-LXDM-Autostart=true
LXDm will automatically pick this up and launch the keyboard when the login screen loads.
Method 3: Use a custom script (for conditional logic)
If you want to only start the keyboard if a touchscreen is detected (smart for flexible setups), write a quick shell script. Save this as /usr/local/bin/start-touch-keyboard.sh:
#!/bin/sh # Check for a touch input device if ls /dev/input/event* | grep -qi touch; then matchbox-keyboard -x 0 -y 400 & # Adjust position to your screen fi
Make it executable:
chmod +x /usr/local/bin/start-touch-keyboard.sh
Then update /etc/lxdm/lxdm.conf to use this script instead:
greeter-setup-script=/usr/local/bin/start-touch-keyboard.sh
3. Test it out
Restart LXDm to apply changes without a full reboot:
systemctl restart lxdm
Or just reboot your Cubieboard. You should see the virtual keyboard pop up automatically when the login screen appears.
Quick note on file locations
- LXDm’s main config:
/etc/lxdm/lxdm.conf - Global autostart desktop files:
/usr/share/lxdm/autostart/or/etc/lxdm/autostart/ - Custom scripts:
/usr/local/bin/is the standard spot for user-added binaries
内容的提问来源于stack exchange,提问作者Joe Joe Ngigí

