Yeah. Grep | cut -f1 from that script is similar to the awk line I use except that I also only print the first match (if there are multiple matches) whereas that script will print all of them which I think will cause problems if you have a device attached multiple timex.
Sent from my phone. Sorry if brief. > On 24 Sep 2017, at 13:44, Yethal <[email protected]> wrote: > > W dniu niedziela, 24 września 2017 13:45:19 UTC+2 użytkownik Sean Hunter > napisał: >> Hey there, >> >> I was trying out attaching usb devices to qubes and thought this might be >> useful to other people. If you have a device with a complicated description >> (eg a Yubikey) it can be a pain to figure out what device ID it's being >> attached to in sys-usb so you can use qvm-usb attach to send it to an AppVM. >> [sean@dom0 ~]# qvm-usb >> BACKEND:DEVID DESCRIPTION USED BY >> fedora-25:1-1 QEMU_QEMU_USB_Tablet_42 >> p:1-1 QEMU_QEMU_USB_Tablet_42 >> sys-firewall:1-1 QEMU_QEMU_USB_Tablet_42 >> sys-usb:1-3 Yubico_Yubikey_4_OTP+U2F+CCID >> sys-usb:1-6 0489_e076 >> vault:1-1 QEMU_QEMU_USB_Tablet_42 >> >> Typing qvm-usb, looking down for where my Yubikey is, then looking accross >> for the sys-usb:1-3 next to it, then typing qvm-usb attach somevm >> sys-usb:1-3 will get pretty old pretty fast. >> >> Luckily, unix is awesome. I have created a couple of small shell functions >> which search the output of qvm-usb on the description and attach or detach. >> Thus: >> [sean@dom0 ~]# usb-attach somevm Yubi >> [sean@dom0 ~]# qvm-usb >> BACKEND:DEVID DESCRIPTION USED BY >> fedora-25:1-1 QEMU_QEMU_USB_Tablet_42 >> p:1-1 QEMU_QEMU_USB_Tablet_42 >> sys-firewall:1-1 QEMU_QEMU_USB_Tablet_42 >> sys-usb:1-3 Yubico_Yubikey_4_OTP+U2F+CCID somevm >> sys-usb:1-6 0489_e076 >> vault:1-1 QEMU_QEMU_USB_Tablet_42 >> >> ...and likewise... >> [sean@dom0 ~]# usb-detach somevm Yubi >> >> If you like them you could put them (or something similar) in your ~/.bashrc >> in your dom0. >> >> Here they are: >> function usb-attach() { >> qvm-usb attach "${1}" $( qvm-usb | awk "/${2}/"'{print $1;exit}' ) >> } >> >> function usb-detach() { >> qvm-usb detach "${1}" $( qvm-usb | awk "/${2}/"'{print $1;exit}' ) >> } >> >> >> Cheers, >> >> Sean > > Great job! I use Micah Lee's script adapted to fit my usb devices > https://micahflee.com/2016/12/qubes-tip-making-yubikey-openpgp-smart-cards-slightly-more-usable/ > > -- > You received this message because you are subscribed to the Google Groups > "qubes-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/qubes-users/25a26bb2-70d3-43dc-823b-8ff0ddaa734f%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "qubes-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/qubes-users/408D4BFD-3AD7-4803-8ACE-998D5959989E%40uncarved.com. For more options, visit https://groups.google.com/d/optout.
