-
Notifications
You must be signed in to change notification settings - Fork 7
/
run_ev_helper.sh
54 lines (39 loc) · 1.21 KB
/
run_ev_helper.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
KBD_COUNT=1
MOUSE_COUNT=1
METHOD="by-id"
if [[ $1 == "by-path" ]]; then
METHOD="by-path"
fi
chmod 755 modify_qemu.sh
chmod 755 uninstall.sh
#This needs to run with elevated privileges
if [ $EUID -ne 0 ]
then
echo "Please run this as root!"
exit 1
fi
#checking for evdev devices, removing old changes, updating qemu.conf
./uninstall.sh
./modify_qemu.sh $METHOD
NEW_DOMAIN="<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>"
echo $NEW_DOMAIN > evdev.txt
echo "" >> evdev.txt
echo " <qemu:commandline>" >> evdev.txt
for entry in `ls -l /dev/input/$METHOD/ | grep "event*"`
do
KBD_M=`echo "$entry" | rev | cut -c -4 | rev`
if [ "$KBD_M" = "ouse" ]
then
echo " <qemu:arg value='-object'/>" >> evdev.txt
echo " <qemu:arg value='input-linux,id=mouse"$MOUSE_COUNT",evdev=/dev/input/$METHOD/$entry'/>" >> evdev.txt
((++MOUSE_COUNT))
elif [ "$KBD_M" = "-kbd" ]
then
echo " <qemu:arg value='-object'/>" >> evdev.txt
echo " <qemu:arg value='input-linux,id=kbd"$KBD_COUNT",evdev=/dev/input/$METHOD/$entry,grab_all=on,repeat=on'/>" >> evdev.txt
((++KBD_COUNT))
fi
done
echo " </qemu:commandline>" >> evdev.txt
echo "Success! Results are in evdev.txt "