Some More keyboard Shenanigans with my virtual machine[THIS TIME WITH RGB CONTROL PRESENT ON HOST AND GUEST]

OKAY, original post is here

https://forum.level1techs.com/t/somewhat-solved-some-weird-keyboard-shenaningans-in-my-virtual-machine/145091

okay, now that we are up to speed, I finally decided to mess around with getting rgb control working for both the host and guest.

During this process I also made my virtual machine headless by going with looking glass and buying a simple dummy plug,this is important, as I set Windows up to Login automatically, so that looking glass host would start, and as luck would have it, I forgot to set my keyboard in the standard bios mode(this one has no rgb control, and defaults to base profiles stored on keyboard), and I noticed I got a code 10 from the device manager.

Basically meaning that my original assumption about the rgb controller blocking the keyboard from even working out in the VM, was wrong, the VM could see the keyboard, but could not Start it. So the question was, what exactly was blocking this thing.

And then I remembered, I had installed ckb-next to control my rgb profiles on linux, so I disabled the daemon that allows that to run on linux, started the VM, and more or less, I could now edit the keyboard with the Windows VM, and of course corsairs iCUE software, with this I found out that my keyboard has some basic hardware profiles, but these hardware profiles are, limited to say the least.

So then what were my options? Could i just disable this daemon every-time I start the VM? Well sure, but I’m now stopping the daemon, starting up virt-manager, starting looking glass, starting the VM, every single time I want to use it, also, conversely it seems like when I kill the VM I have to reset the keyboard, and then restart the daemon to get the keyboard working properly in the host again.

No, too much fooling around in all that, so I dusted off some of my programming chops to create a script that would pull all of this of for me at once, and well, behold:

THE GOODIES

#!/bin/bash

STR=“looking-glass-client”

systemctl stop ckb-next-daemon #STOPS CKB-NEXT-DAEMON TO ALLOW VM TO HOOK IN PROPERLY

virsh start Windows #STARTS VM

cd /home/william/LookingGlass-Release-B1/client/build # STARTS LOOKING GLASS
./looking-glass-client -r -s -F egl:vsync=yes

while ( pgrep -x “$STR” > /dev/null ); do #RUNS WHILE LOOKING GLASS IS ON THEREFORE LOOKING GLASS BEING CLOSED TURNS OFF THE VM AND RESETS THE USB DEVICES FOR LINUX AUTOMAGICALLY
echo “”
done

virsh shutdown Windows #STOPS VM

systemctl start ckb-next-daemon #STARTS CKB-NEXT-DAEMON AGAIN

for i in /sys/bus/pci/drivers/[uoex]hci_hcd/:; do #RESETS ALL USB DEVICES, JUST IN CASE OF MULTIPLE DEVICES
[ -e “i" ] || continue echo "{i##/}" > "{i%/*}/unbind" echo "{i##/}” > “${i%/*}/bind”
done

What’s particularly neat about this bash script is that it attempts to watch the looking glass client so that whenever you close the client it resets everything back and Linux takes back over like a champ at this point