Skip to content

Commit

Permalink
Remap mouse buttons when a matching device is connected.
Browse files Browse the repository at this point in the history
  • Loading branch information
threedaymonk committed May 15, 2011
1 parent d2fa3c5 commit 285b86c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions remap-buttons
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Detect when the named device is plugged in and remap buttons accordingly
# Usage: remap-buttons "Foo" "1 2 3 4 5 6 7 8"

device=$1
map=$2
last_state=-1

while [ 1 ]
do
xinput list | grep "$device" > /dev/null
if [ $? -eq 0 ]; then
state=1
else
state=0
fi
if [ $state -ne $last_state ]; then
last_state=$state
if [ $state -eq 1 ]; then
xinput set-button-map "$device" $map
fi
fi
sleep 10
done

0 comments on commit 285b86c

Please sign in to comment.