You will need a microswitch and some wires to plug it into the GPIO port of your Raspberry with Octoprint and the Filament runout reloaded plugin.
This is the switch I used https://grobotronics.com/microswitch-mini-spdt-on-on-with-roller.html
You will need support to print it.
The lid slips in and holds nicely with friction, so no screws needed.
Added bonus: This works also nicely as a filament guide.
Update: I revised the case so that it stands off the frame and more in line with the extruder.