Update: Added a simple alarm version use 5V magnetic buzzer (KPX-1205A) and 3 LR44 batteries.
Update: Added an IoT version of the switch.
Simple filament runout switch connects to the extruder with a 4mmx50mm PTFE tubing. Suitable for Titan extruder. The switch is bi-directional, you can also make a small adapter connects to the PTFE tubing to install the switch near your extruder or near the filament roll. Uses KW11-N micro limit witch (10x20mm) with roller arm. For 1.75mm filament.
Secure the wiring with the body use cable tie. The switch can also be bolted to the body use 2 M2x10mm screws but is optional.
See how it works:
Switch only: https://youtu.be/TcmyC_DIx4Q
IoT version: https://youtu.be/CDAZRx1KVPU
For example wiring and Marlin configuration, see https://www.instructables.com/id/IoT-Enabled-Smart-Filament-Runout-Switch/