Page 1 of 1
Sync keyboard layout switch between guest and host in seamless mode
Posted: 11. Apr 2017, 18:41
by Malamut
I try to use VirtualBox in seamless mode to run browser inside guest. Both host and guest systems are running on ubuntu 17.04 (unity in host, xfce in guest) and all work fine except switching between keyboard layouts. Of course, I've disable auto capture of keyboard in guest (because I need hosts keybindings). And now then I press Alt+Shift inside browser - keyboard layout changed in host system, not in guest. So I continue to write in same language. How to fix it? I need any ability to change keyboard layout in seamless mode.
Re: Sync keyboard layout switch between guest and host in seamless mode
Posted: 11. Apr 2017, 22:14
by socratis
Malamut wrote:I need any ability to change keyboard layout in seamless mode.
As far as I know, keyboard doesn't change differently in seamless compared to everything else. What might be confusing is who has the focus at the time that you switch the layout, the guest or the host. You got to be really careful with that part. I'm keeping the layout switching different on the host and on the guest personally...
Re: Sync keyboard layout switch between guest and host in seamless mode
Posted: 11. Apr 2017, 22:18
by Malamut
Well, I've 'solve' this problem with very durty hack: I've write script fo host system and add standard Alt+Shift hotkey to launch it:
Code: Select all
current=$(gsettings get org.gnome.desktop.input-sources current | sed -E "s/^uint32\s+//")
[ "$current" == '0' -o "$current" == '1' ] || exit 0
new=$(((current+1)%2))
gsettings set org.gnome.desktop.input-sources current $new
xkbmap='us+ru:2'
case "$new" in
0) xkbmap='ru+us:2' ;;
1) xkbmap='us+ru:2' ;;
esac
VM=aa-bb
user=user
pass=passwd
if vboxmanage list runningvms | grep -q $VM; then
vboxmanage guestcontrol a002b8aa-16b3-4b5d-be4c-3f221d66f5f3 --username "$user" --password "$pass" run -E PATH=$PATH -E DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS -E XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR -E DISPLAY=:0.0 -- /bin/bash -c "gsettings set org.gnome.desktop.input-sources current $new; setxkbmap $xkbmap"
fi
This is not a good solution, but it's work. If anybody know a good way to solve the problem - would be grateful.