You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
828 B
34 lines
828 B
#!/usr/bin/env perl
|
|
|
|
use warnings;
|
|
use strict;
|
|
die "Usage: $0 VID PID\n" unless @ARGV == 2;
|
|
|
|
my $vid = shift;
|
|
my $pid = shift;
|
|
my $prefix = '/dev/serial/by-id/';
|
|
my @paths = `ls $prefix`;
|
|
my %devices;
|
|
|
|
for my $path (@paths) {
|
|
chomp($path);
|
|
next unless -l $prefix . $path;
|
|
my @data = `udevadm info -q property --name=${prefix}${path}`;
|
|
for my $line (@data) {
|
|
chomp($line);
|
|
my ( $key, $val ) = split( /=/, $line, 2 );
|
|
$devices{$path}{$key} = $val;
|
|
}
|
|
if ( ( hex $devices{$path}{'ID_VENDOR_ID'} == hex $vid )
|
|
&& ( hex $devices{$path}{'ID_MODEL_ID'} == hex $pid ) )
|
|
{
|
|
|
|
if ( $devices{$path}{'ID_MM_CANDIDATE'} ) {
|
|
warn "Yikes. ModemManager wants to pwn your keyboard";
|
|
}
|
|
|
|
print $devices{$path}{DEVNAME};
|
|
exit(0);
|
|
}
|
|
}
|