Just over a week ago, I decided to take one of my Raspberry Pi boards I had laying around my shop and implement an Octoprint server for my TAZ 6. I was, and still am blown away by the genius behind Octoprint. If you are unfamiliar with Octoprint, in summary, it turns a Raspberry Pi into a web server for your 3D printer. It can do everything from printing a gcode file, to slicing an STL file. Additionally, it is loaded with great features and is very flexible with integrating your own hacks. I use Simplify3D for slicing and was apprehensive to try Octoprint because I was unsure of compatibility. I am so glad I tried it - it works awesome with S3D! Get more info on Octoprint here.
Octoprint has quite a few extremely convenient plugins including Filament Sensor Reloaded by Kontakt. This convenient plugin uses a selected pin on the Raspberry Pi in combination with a filament sensor to pause your printing if you run out of filament. Combine that with Octoprint's 'Pause Script' setting and you can send virtually any gcode when you run out of filament. In my case, I set Octoprint to play a series of beeps and run an M600 filament change command when my filament sensor triggers.
For my sensor, I used Lulzbot's Feed Tube Spinner concept and redesigned it with a built in optical sensor. Installing it is as simple as replacing Lulzbot's Feed Tube Spinner and running 3 conductors to your Rasberry Pi header pin.