Hack optical mouse to make filament detector?

I was hoping that someone has figured a way to make a filament runout detector using a usb optical mouse. I was looking at an old Mac usb mouse, and it has everything needed for the job. The “click” switch can sense the filament and the optics will make sure it is moving. Just plug it in to the PI usb socket and (just!) modify the Octoprint software. No need to modify the printer’s pcb.

Pete

I believe this thread should help you out! https://forum.lulzbot.com/t/poor-mans-pause-on-filament-run-out/5529/1