I'm trying left handed mousing, and I want to be able to easily switch between right handed mode and left handed mode. There is a utility for Windows called SwapMouseButtons that allows to bind a key for that switch - both swapping the buttons and changing the pointer's direction.

I would like to do something similar for KDE in a shell script.

Swapping the buttons is easy with xinput, but I'm having a hard time changing the mouse theme to a left handed theme from the command line. I also prefer to find a KDE solution for the button swapping, as changes made via xinput are session-bound and KDE settings are saved. I wouldn't like to have a left handed theme with right handed buttons after a reset...

The problem is, I can't find much documentation on KDE's command line utilities. I found this post that suggests using kapplymousetheme, which seems promising, but I can't figure out how to use it(no man page, no --help flag...)

I've also found that kcmshell4 cursortheme opens the mouse theme dialog, and that kcmshell4 accepts the --args flag for sending arguments to the module, but I couldn't find nor figure out what arguments I need to send to just change the mouse theme without opening the dialog(if that's even supported).

I should also note that I want these changes to take effect immediately. Changing a configuration file and having to restart the system(or even just X or KDM) won't do, though if I can reload that configuration file(with a command line utility, of course) so that the changes will take effect immediately that will be fine.

Thanks in advance!

  • I'm fairly sure that changing KDE system settings from the command line isn't possible generally. – Sparhawk Jun 16 '14 at 2:12
  • currently i am scripting my shortcuts and mouse settings for kde neon, which seems to work – sjas Apr 28 '18 at 17:56

Two years late but I just re-solved this for Plasma 5. Maybe this will help the next person who comes along for this answer.

Here is a KDE method I use for swapping the mouse buttons around. Maybe the same thinking can be applied to altering the theme too.

Essentially, all you have to do is change MouseButtonMapping in $HOME/.config/kcminputrc between LeftHanded and RightHanded and then call kcminit mouse. Here is a script to do just this:


CURRENT=`kreadconfig --file $CONFIG --group Mouse --key MouseButtonMapping`

if [ $CURRENT = "LeftHanded" ]; then
  kwriteconfig --file $CONFIG --group Mouse --key MouseButtonMapping RightHanded
elif [ $CURRENT = "RightHanded" ]; then
  kwriteconfig --file $CONFIG --group Mouse --key MouseButtonMapping LeftHanded

kcminit mouse

Note that the file in KDE Plasma 4 is $HOME/.kde/share/config/kcminputrc and in Plasma 5 it is $HOME/.config/kcminputrc so you may have to edit the script to suit.

I then add this script to my main KDE apps menu so that I can assign a global hotkey for it.

UPDATE 2018:

Due to KDE config file changes the script now looks like this:


CURRENT=`kreadconfig --file $CONFIG --group Mouse --key XLbInptLeftHanded`

if [ $CURRENT = "true" ]; then
  kwriteconfig --file $CONFIG --group Mouse --key XLbInptLeftHanded false
elif [ $CURRENT = "false" ]; then
  kwriteconfig --file $CONFIG --group Mouse --key XLbInptLeftHanded true

kcminit mouse

You can easily change to left-handed as follows:

 xmodmap -e "pointer = 3 2 1"

You can find the documentation on https://help.ubuntu.com/community/MouseCustomizations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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