I have bluetooth mouse xinput setting script to run whenever i have connect the mouse. Currently I'm simply alias the short key as 'bm' for that bash file execution but I want to know if there is automatic way to execute the bash file or alias command whenever it detects the mouse connection.
Thank in advance!
ubuntu 16.10
Best Answer
I would use a .rules file.
First, find out the
ID_VENDOR_ID
and theID_MODEL_ID
of your mouse. Disconnect the mouse, run this command and connect the mouse (the|grep ID
part is only to filter information that you don't need).Lets say that you get these values:
Now create a file in the rules folder (96 is the priority of the rule):
Add these two lines using your values for the
ID_VENDOR_ID
andID_MODEL_ID
. If you don't want to do anything when you remove it, don't include the second line.You can test that it works creating the two scripts:
Add something like this (change
add
toremove
in the other one):Finally, tail the file with
tail -f /tmp/myusb.log
and connect/disconnect your mouse. You should see that the text gets added to the file.