blob: a66d6df3e362a2a80990dc03688923726384925c (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
if ! qvm-check -q --running "$qube"; then
echo Go back... | dmenu-unlinked -p "$qube needs to be running, in order to attach $(echo "$chosefrom" | cut -f1 -d\ | awk '{print tolower($0)}') devices to it." > /dev/null 2>&1
else
case $chosefrom in
Audio*) device_type='device mic';;
Block*) device_type=block;;
USB*) device_type=usb
esac
devices_list=$(qvm-$device_type)
device=1
while [ -n "$device" ]; do
device=$(echo "$devices_list" | dmenu-unlinked -l 16 -p "$qube:")
if [ -n "$device" ] && [ "$(echo "$device" | wc -l)" -eq 1 ]; then
device_id=$(echo "$device" | cut -f1 -d\ )
if [ "$device_type" = block ]; then
device_name=$(echo "$device" | awk '{print $2,$3}')
holds_qube=$(echo "$device" | awk '{print $4}')
else
device_name=$(echo "$device" | awk '{print $2}')
holds_qube=$(echo "$device" | awk '{print $3}')
fi
if [ -z "$holds_qube" ]; then
if nyprompt "Attach '$device_name' to $qube?"; then
unset device
qvm-$device_type attach -q "$qube" "$device_id" ||
echo Go back... | dmenu-unlinked -p "Error: Failed to attach device!" > /dev/null 2>&1
fi
elif [ "$holds_qube" = "$qube" ]; then
if nyprompt "Detach '$device_name' from $qube?"; then
unset device
qvm-$device_type detach -q "$holds_qube" "$device_id" ||
echo Go back... | dmenu-unlinked -p "Error: Failed to detach device!" > /dev/null 2>&1
fi
else
if nyprompt "Detach '$device_name' from $holds_qube and attach it to $qube?"; then
unset device
qvm-$device_type detach -q "$holds_qube" "$device_id" &&
qvm-$device_type attach -q "$qube" "$device_id" ||
echo Go back... | dmenu-unlinked -p "Error: Failed to handle device!" > /dev/null 2>&1
fi
fi
fi
done
fi
|