I'm using Linux Mint 17 with the Cinnamon desktop environment and I want to quickly toggle between left-handed and right-handed settings for the mouse by using a keyboard shortcut.
My solution is based on the solution for ubuntu given here. I'm answering my own question for the Cinnamon case as a service to those who face the same problem in the future. You're welcome!
The code samples given below are meant to be cut&pasted to the terminal. If root access is needed, sudo is used as part of the command.
First, create a script file that toggles the setting:
sudo tee /usr/local/bin/mouse_handedness_toggle <<'EOF' #!/bin/bash gsettings_key=org.cinnamon.settings-daemon.peripherals.mouse current_setting=$(gsettings get $gsettings_key left-handed) if [[ "$current_setting" == "true" ]]; then new_setting=false else new_setting=true fi gsettings set $gsettings_key left-handed "$new_setting" EOF
Change the permissions of the file, so it can be run.
sudo chmod 755 /usr/local/bin/mouse_handedness_toggle
Test that it works by running the script from the command line:
If it works, go to
Menu => System Settings => Keyboard => Keyboard Shortcuts => Add Custom Shortcut, and set
Name as e.g. "Toggle left handed mouse" and
/usr/local/bin/mouse_handedness_toggle. Finally assign a keyboard binding to the newly created custom shortcut, and you're done!
With small modifications, this approach can be used to change any setting in Cinnamon with a keyboard shortcut. There are gsettings commands for listing the keys that are used and their values, see the man page.