commit 5b2b76ad7e470518e9bdc5d0cf7b9b2650ad672e Spenser Truex <spensertruexonline@gmail.com> 2019-04-22 14:00:33 -0700 Initial commit
commands.conf | 2 ++ forking.pl | 11 +++++++++++ monitor.pl | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+)
diff --git a/commands.conf b/commands.conf new file mode 100644 index 0000000..1465899 --- /dev/null +++ b/commands.conf @@ -0,0 +1,2 @@ +monitor.pl -n 'DeathAdder Elite' -d 'usb' +monitor.pl -n 'Rosewell' -d 'usb' diff --git a/forking.pl b/forking.pl new file mode 100755 index 0000000..e5582b2 --- /dev/null +++ b/forking.pl @@ -0,0 +1,11 @@ +#/usr/bin/perl +use strict; +use warnings; +open my $com, '<', 'commands.conf'; +for(<$com>) { + my $f = fork(); + if (defined $f) { + print; + `$_`; + } +} diff --git a/monitor.pl b/monitor.pl new file mode 100755 index 0000000..0c329aa --- /dev/null +++ b/monitor.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl +use warnings; +use strict; +open my $udev, '-|', qw(udevadm monitor); +my $xname; +my $devname; +for(@ARGV) { + $_ = shift @ARGV; + if($_ eq '-n') { + $xname = shift @ARGV; + } + if($_ eq '-d') { + $devname = shift @ARGV; + } +} +while (<$udev>) { + my ($source, $ts, $action, $dev, $sys) = split; + print; + if ($action eq 'add' and $dev =~ /usb/) { + my $xlist = `xinput`; + $xlist =~ /DeathAdder Elite\W+id=(.*?)\W+/; + `xinput set-prop $1 153 0.114285, 0.000000, 0.000000, 0.000000, 0.114285, 0.000000, 0.000000, 0.000000, 1.000000` + } +} +# Add this udev rule to automatically run this script when mouse is connected. +# ACTION=="add", RUN+="/usr/bin/mouseset" +# to file /etc/udev/rules.d/100-usb.rules