Sunday, April 21, 2013

Logitech Unifying Mice : remapping Buttons

How to remap buttons for a Logitech Unifying device
Comment changer l'action des boutons pour un périphérique Logitech Unifying

example of my M505 under linux Mint 13 (cinnamon 64) & 14 (xfce 64)

exemple de ma M505 sous linux Mint 13 (cinnamon 64) & 14 (xfce 64)

#this script switches between two or more mapping for your unifying Logitech device
#you need to manually edit the device name, since i couldn't automate this command
#to know your current mapping use >xev< command, for your device list use >xinput list<

#to add an option, just add a new "elif"
#this has been done for M505, but should work for others
#refer to and more informations

NAME='Logitech Unifying Device. Wireless PID:101d'
#looking for device ID
ids=$(xinput list | grep "$NAME" | grep -o -e "id=.." | xargs | sed "s/id=//g")
echo -e "\033[0;36myour are going to switch mapping settings of your \033[0;0m Logitech Mice! \033[0;36m"
echo -e "make sure your device is \033[0;0m$NAME\033[0;36m"
echo "check using >xinput list< command first"
echo -e "your mice ID is : \033[0;0m$ids\033[0;36m"
echo "option 1 is remapped settings : custom left/right click"
echo "option 2 is default mappig!"
read -p 'option 1/2? (anything else to exit):' opt0
echo "your choice is $opt0"
if [ $opt0 -eq 1 ]
echo -e "setting opt1 (\033[0;0m$opt0\033[0;36m)"
#calling xinput to remap the buttons
echo `xinput set-button-map $ids 6 2 7 4 5 1 3`
elif [ $opt0 -eq 2 ]
echo -e "setting opt2 (\033[0;0m$opt0\033[0;36m)"
#calling xinput to remap the buttons
echo `xinput set-button-map $ids 1 2 3 4 5 6 7`
#sleep 10
echo -e "\033[1;31msomething went wrong : \033[0;36mnot a valid option!"
echo -e "\033[0;0mwill now exit"
sleep 10

Making the script executable and building the lancher : 
Rendre le script exécutable et fabriquer le lanceur :  

right clic on the .sh file, and choose "properties" :
faire un clic droit sur le fichier .sh, puis choisir "propriétés:

Go on the desktop, right clic and choose "create a launcher":
Aller sur le bureau, faire un clic droit et choisir "créer un lanceur":

choose application in terminal / choisir application dans un terminal

How the scrip looks and work : 
Comment le script se présente et fonctionne : 

if invalid number is choosen : (to exit or by mistake)
si un nombre non prévu est saisi : (pour quitter ou par erreur)

Known issues / problèmes connus
with opt1, holding left-roller doesn't behave as holding the left clic (in fact it react as a doucle left clic...)

avec l'option 1, le maintien du clic roulette-gauche ne se comporte pas comme un clic gauche maintenu (en fait il réagit comme un double clic gauche!)

Enjoy !