Mouse driver reset causes logout

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
epadget1

Mouse driver reset causes logout

Post by epadget1 »

Hello all,
I've encountered a strange problem where running a script meant to reset a misbehaving mouse driver caused Mint to log out. I'm running Maya MATE on my laptop. The problem does not appear to be reproducible -- the script worked just fine before causing a logout this morning, and hasn't done it again since then. However, if there's something I can change to keep this from happening again I would like to.

I wrote the script ("/usr/bin/fixmouse") based on some suggestions online to fix my laptop mouse when it becomes unresponsive or jumpy:

Code: Select all

#!/bin/bash
#resets mouse if it gets stuck
rmmod psmouse
modprobe psmouse

echo done.
I've been calling it by typing "sudo fixmouse".

Am I doing something stupid or risky? I guess I don't really understand very well what rmmod and modprobe are doing, so I might be missing something obvious.

Any thoughts about how to keep it from happening again would be appreciated! Thanks!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: Mouse driver reset causes logout

Post by xenopeek »

rmmod removes the psmouse kernel module, and modprobe loads it again. Basically, switching it off and then on again. Instead of rmmod, the manpage for rmmod is suggesting you do modprobe --remove instead. Adding --verbose makes it verbose, so it will tell you what it is doing and you don't need the final echo as feedback. So change it to:

Code: Select all

#!/bin/bash
#resets mouse if it gets stuck
modprobe --remove --verbose psmouse
modprobe --verbose psmouse
Test the modprobe --remove though, as there may be a reason you need to do rmmod for this problem.
Image
epadget1

Re: Mouse driver reset causes logout

Post by epadget1 »

xenopeek wrote:rmmod removes the psmouse kernel module, and modprobe loads it again. Basically, switching it off and then on again. Instead of rmmod, the manpage for rmmod is suggesting you do modprobe --remove instead. Adding --verbose makes it verbose, so it will tell you what it is doing and you don't need the final echo as feedback. So change it to:

Code: Select all

#!/bin/bash
#resets mouse if it gets stuck
modprobe --remove --verbose psmouse
modprobe --verbose psmouse
Test the modprobe --remove though, as there may be a reason you need to do rmmod for this problem.
I will give this a try. Thank you Vincent!
epadget1

Re: Mouse driver reset causes logout

Post by epadget1 »

xenopeek wrote:rmmod removes the psmouse kernel module, and modprobe loads it again. Basically, switching it off and then on again. Instead of rmmod, the manpage for rmmod is suggesting you do modprobe --remove instead. Adding --verbose makes it verbose, so it will tell you what it is doing and you don't need the final echo as feedback. So change it to:

Code: Select all

#!/bin/bash
#resets mouse if it gets stuck
modprobe --remove --verbose psmouse
modprobe --verbose psmouse
Test the modprobe --remove though, as there may be a reason you need to do rmmod for this problem.
Apparently that didn't fix it. Five minutes after making the suggested changes to the script, I ran it as before and was logged out again. Trying it again now, there's no problem. I get:

Code: Select all

sudo fixmouse
[sudo] password for : 
rmmod /lib/modules/3.2.0-23-generic/kernel/drivers/input/mouse/psmouse.ko
insmod /lib/modules/3.2.0-23-generic/kernel/drivers/input/mouse/psmouse.ko 
Any more thoughts?
Locked

Return to “Scripts & Bash”