Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This one bugs me.

I fashioned this handy script to swap the left and right mouse buttons over: [My mouse is a Razer]

/usr/bin/xinput set-button-map `xinput list | grep 'Razer' | grep -o \=[0-9]* | grep -o [0-9]*$` 3 2 1 4 5 6 7 8 1 10 11 12 13

When I run this in a Terminal it works.

When I go to Startup Application Preferences -> Add and then literally paste the above into the command field as an 'Additional startup program' It does not run on startup.

Why not?

I'm using Ubuntu 11-10 but this also applied to the 10-10

share|improve this question
up vote 2 down vote accepted

I've had various things like that fail before. I'm honestly not sure if it's just a problem with the way the commands are stored or an issue with whatever limited environment these commands are run with.

Either way there are two options that have both worked for me:

  • Write a little bash script. It can pretty much be your command with a #!/bin/bash stanza at the top (I've broken it up to read better):

    DEV=$(xinput list | grep 'Razer' | grep -o \=[0-9]* | grep -o [0-9]*$)
    /usr/bin/xinput set-button-map $DEV 3 2 1 4 5 6 7 8 1 10 11 12 13

    Then just save that somewhere like ~/.mousescript and call bash ~/.mousescript as your start-up command.

  • Or just wrap your command in bash:

    bash -c "/usr/bin/xinput set-button-map `xinput list | grep 'Razer' | grep -o \=[0-9]* | grep -o [0-9]*$` 3 2 1 4 5 6 7 8 1 10 11 12 13"
share|improve this answer
yep I wrapped it in a bash -c and it works fine now - thanks – andy boot Mar 27 '12 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.