Something iffy with changing monitors and xinput?

Hey all,

First I just want to say that I’m loving gnome, and I’m loving how this desktop is evolving bit by bit each time .

I updated from 3.38 to 42.1 recently and I have a bit of an issue with my setup:

  1. I have a “mouse.sh” setup script that just runs some xinput commands for me to set up my logitech trackball mouse ( so the “back” button is now a scroll wheel)
  2. in 3.38 I could just make a .desktop file, and add it to auto-launch at startup
  3. now in 42.1 I can’t run the .desktop file, but I can still run the original mouse.sh
  4. If I disconnect the monitor, and reconnect it ( ie: when I’m moving my laptop from the office to the lounge and back again) my mouse settings are gone, and I have to run the mouse.sh script again.

Part 4. never happened to me on 3.38 so I’m wondering if there’s a something that’s changed with the update to gnome that… I don’t know… resets the xorg server when monitor configuration changes?

More importantly: is there a way to run the script when monitors change?

FWIW I couldn’t find any other software or method that would set up the trackball to function like I want it to.
Here’s the script as I have it:. I have to run this each time, from the shell, when I disconnect/reconnect my monitor.

#!/bin/bash
xinput set-prop "Logitech USB Trackball" "libinput Scroll Method Enabled" 0 0 1
xinput set-prop "Logitech USB Trackball" "libinput Button Scrolling Button" 8
xinput set-button-map "Logitech USB Trackball" 1 2 3 4 5 6 7 0 0
xinput set-prop "Logitech USB Trackball" 'libinput Accel Speed' 0.9