Apress - Smart Home Automation with Linux (2010)- P21:Linux users can now control their homes remotely! Are you a Linux user who has ever wanted to turn on the lights in your house, or open and close the curtains, while away on holiday? Want to be able to play the same music in every room, controlled from your laptop or mobile phone? Do you want to do these things without an expensive off-the-shelf kit | CHAPTER 2 APPLIANCE HACKING This might be to record the sound with vox_record. sh bin bash LOGFILE var log voxrecordpid DIR_INCOMING usr local media voxrecord if 1 start then FILENAME mktemp -p DIR_INCOMING .wav arecord -f cd -t wav FILENAME dev null dev null 2 1 PID echo PID LOGFILE fi if 1 stop then PID cat LOGFILE kill PID rm LOGFILE fi or play back each sound in the directory with bin bash DIR_INCOMING usr local media voxrecord for F in DIR_INCOMING .wav do play F done or even delete them all through bin bash DIR_INCOMING usr local media voxrecord rm -f DIR_INCOMING Naturally there is a lot more scope here to support the deletion of individual recordings and so on. But this represents the idea. Note The Minerva system abstracts these ideas out into Minx which eliminates the need for separate executables for each Arduino application. Minerva will be covered in Chapter 7. 78 CHAPTER 2 APPLIANCE HACKING Joysticks for Input Joysticks particularly old ones make wonderful input devices because they interface with the parallel port on most standard sound cards and are physical rugged. This enables the buttons to be reused particularly as foot pedals to control software. Indeed this provides a very cheap way of adding a dictation module to your machine without the need for an Arduino providing the input. In addition to triggering individual events on a Linux machine such as requesting a weather report or the state of the machine it can also feed messages to other applications. mplayer for example can operate in slave mode allowing commands to be fed to it from the standard input or a named pipe. Similarly the X Window TV-viewing software xawtv comes with xawtv-remote to change channel and volume as per most remote controls giving you capture on off and screenshot facilities. This makes it possible to freeze frame magic shows to see how they do it You can read the joystick directly from dev js0 but it is usually better to use an abstraction .