Disable desktop switching with the scroll wheel in Lubuntu?

I still want to keep my multiple desktops, I want to disable switching desktops with the mouse.


Starting with Lubuntu 14.04 or earlier, the config file format and solution became slightly different from @SWrobel's answer. Then in Ubuntu 17.10 (or earlier), things changed again.

The following instructions apply to the current situation (Ubuntu 17.10 and later).

  1. Remove the following lines from ~/.config/openbox/lubuntu-rc.xml to disable any scroll wheel desktop switching in a window, with and without modifier keys. (Keep the outer <context …> … </context> element though.)

    <context name="Frame">
      […]
      <mousebind button="A-Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="A-Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <mousebind button="C-A-Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="C-A-Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <mousebind button="A-S-Up" action="Click">
        <action name="SendToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="A-S-Down" action="Click">
        <action name="SendToDesktop">
          <to>next</to>
        </action>
      </mousebind>
    </context>
    
  2. Also remove the following lines to disable any scroll wheel desktop switching on the desktop background:

    <context name="Desktop">
      <mousebind button="A-Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="A-Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <mousebind button="C-A-Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="C-A-Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
      <mousebind button="Right" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
    </context>
    
  3. Also remove the following lines to disable any scroll wheel desktop switching while moving a window around:

    <context name="MoveResize">
      <mousebind button="Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <mousebind button="A-Up" action="Click">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind button="A-Down" action="Click">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
    </context>
    
  4. Execute this to let the settings take effect immediately (source):

    openbox --reconfigure
    

cd ~/.config/openbox
cp lubuntu-rc.xml lubuntu-rc.xml.bak

(this makes a backup file so that when you think you've messed it up you could revert it back.)

leafpad lubuntu-rc.xml

and delete the lines which says;

<mousebind button="UP" action="click">
 <action name="DesktopPrevious" />
<mousebind button="Down" action="click">
 <action name="DesktopNext" />

Log out and Log in back again to see the changes!

if you've messed it up and want to revert it back;

cp lubuntu-rc.xml.bak lubuntu-rc.xml

Answer quoted from Lubuntu docs


I found that inadvertently moving the scroll wheel when my mouse was over bare desktop caused my windows to disappear and a switch to a new desktop with Lubuntu 18.04. This was not what I wanted. I found out how to fix this by looking at:

http://openbox.org/wiki/Help:Bindings

cd ~/.config/openbox
cp lubuntu-rc.xml lubuntu-rc.xml.bak

I edited lubuntu-rs.xml with nano:

nano lubuntu-rc.xml

I found these lines within the file:

<context name="Desktop">
  <mousebind button="Up" action="Click">
    <action name="GoToDesktop">
      <to>previous</to>
    </action>
  </mousebind>
  <mousebind button="Down" action="Click">
    <action name="GoToDesktop">
      <to>next</to>
    </action>

I deleted all these lines except the first one, saved the changes and exited from nano. I made these changes effective with:

openbox –-reconfigure

Moving mouse scroll wheel over bare desktop no longer changed desktops, but it was still possible to change desktops, e.g. by clicking on the corresponding icons on the lxpanel.

More simply, if you do not want to use multiple desktops, setting the number of desktops to one fixes the problem.