Communicate with shell through named pipe

I have written a shell script which reads and executes commands from a named pipe. The script is:

while true; do read cmd <~/.fvwm/PIPE eval "$cmd" done

This script is at “~/.fvwm/”. I can launch this script when I start up:

[code]AddToFunc InitFunction

  • I Function OpenLoader

AddToFunc OpenLoader

  • I Exec rm ~/.fvwm/PIPE && mkfifo ~/.fvwm/PIPE && sh ~/.fvwm/

I can send commands to this script either by doing [code]

~/.fvwm/PIPE echo (whatever)
[/code] at the command line, or by using the following fvwm function:

[code]AddToFunc Loader

  • I Exec echo >~/.fvwm/PIPE “$*”

This could be used via e.g FvwmCommand or FvwmConsole.

It remains to be seen how useful this will be. I imagine it could be useful for taking advantage of shell features such as working directory or aliases. For example, one may wish to set a working directory with “Loader cd” so that new terminal windows which are opened will be in a particular directory (rather than being in whichever directory you started X from). Or you might do “Loader alias xterm=‘xterm -rv’”, and then if you do “Loader xterm &” (without the “&”, the script will wait until the program exits), you will get the alias.