PipeRead and command quoting.

My guess is that it is the single quotes around awk.

Also what might affect is the shell fvwm uses (for example for the $(…) construct), which you can change with ExecUseShell.

No, the problem is with the context this is being called in. Note the following from the original post:

+I PipeRead "echo SetEnv x_width $(xrandr -q | awk '/^\*/{print $2}')"

For a start “+I” is inavlid, since there has to be a space after the “+”, hence: “+ I”. I don’t assume this to be an issue, rather it’s more likely to be a copy/paste error.

What you’re really missing though is that because this is running inside a function “$2” by itself has specific meaning to FVWM in that it’s a positional parameter. Hence what’s actually needed is escaping to protect the expansion of “$2” awk, SetEnv and Echo:

+ I  PipeRead "echo SetEnv x_width $(xrandr -q | awk '/^\*/{print $$$$2}')"

Erostratus, hope that helps.

– Thomas Adam

ROFL! Thomas, your help and explanation are perfect as usual, but the “print $$$$2” just made me laugh out loud :smiley:
Oh the horror of escaping :wink:

It can get a little unweildy, yes. :slight_smile:

Just think it through logically though. What is it that’s operating on “$2”? You should really work backwards from the statement, hence:


  • I PipeRead “echo SetEnv x_width $(xrandr -q | awk ‘/^*/{print $$$$2}’)”[/code]

First you have awk which will strip “$2” outright. If it does that you have nothing left, so we add in our head:


Then we have the SetEnv command. This doesn’t expand anything. Then we have echo – that’s a shell builtin by the time we’re at the shell, but it will try and interpolate anything given to it, hence we add to your list another case for a dollar:


PipeRead – well, yes, that does interpolation, so another dollar:


And finally we have the unseen function name which itself will be interpolating this, hence:


So that’s how many dollars you’d need.

– Thomas Adam

This would be a great point in a FAQ, if it’s not there already. I, at least. found it very enlightening.

It’s not part of any FAQ, but if I expand it a bit (excuse the pun), I’ll add it to the FvwmWiki and the #fvwm channel FAQ when both respective machines are up and in a working order again.

– Thomas Adam