Extracting the xinput device number instead of hardcoding it

I’ve been using my wireless mouse more often these days. XWindows detected it fine and it works without a hitch, hooray! The downside is that as an additional input device, it threw my xinput device numbering off, so the script I was using to rotate the stylus input along with the screen on my tablet PC stopped working. Easy enough to fix by extracting the device number from the output of xinput using the cut command.

The relevant changes were:

xsetwacom set $(xinput | grep eraser | cut -c 55-56) rotate $direction
xsetwacom set $(xinput | grep touch | cut -c 55-56) rotate $direction
xsetwacom set $(xinput | grep stylus | cut -c 55-56) rotate $direction

My rotate-screen script on GitHub