Piperead in FvwmButton

I’m attempting to store some of my dotfiles in a git repo so that I can keep them synced between my laptop and home computer. To allow the one fvwm config to work with two different computers/monitors I wrote the below piperead.

I’m struggling to make the Piperead with the if command work. When I run the if command in a terminal it echos the correct thing but when in the piperead it doesn’t seem to work as the “FvwmIconMan FvwmIconTaskbar” module isn’t swallowed/started.

[code]DestroyModuleConfig FvwmButtons: ButtTaskbar
Piperead ‘echo *ButtTaskbar: Geometry $[vp.width]x22+0-0’
*ButtTaskbar: Font None
*ButtTaskbar: Colorset 10
*ButtTaskbar: Rows 1
Piperead ‘echo *ButtTaskbar: Columns $$(($[vp.width]))’
*ButtTaskbar: Padding 0 0
*ButtTaskbar: Frame 0
*ButtTaskbar: (19x1, Icon icon-opera.svg:16x16, PressIcon icon-opera-pressed.svg:16x16, Padding 0 0, Action (Mouse 1) FuncButtOpera, Action (Mouse 3) Menu OperaWindowOps Rectangle +$left+$top 0 -100m)

Piperead ‘if [ $HOSTNAME = Willie ]; then echo *ButtTaskbar: (1656x1, Left, Swallow “IconTaskbar” “FvwmIconMan IconTaskbar”); else echo *ButtTaskbar: (1018x1, Left, Swallow “IconTaskbar” “FvwmIconMan IconTaskbar”); fi’

#*ButtTaskbar: (1018x1, Left, Swallow “IconTaskbar” “FvwmIconMan IconTaskbar -g -30000-30000”)
#*ButtTaskbar: (1656x1, Left, Swallow “IconTaskbar” “FvwmIconMan IconTaskbar -g -30000-30000”)
*ButtTaskbar: (10x1)
*ButtTaskbar: (40x1, Swallow “stalonetray” “Exec stalonetray -t -c $XDG_CONFIG_HOME/.stalonetrayrc”)
*ButtTaskbar: (20x1, Center, Icon drive-removable-media-3.svg:16x16, Action (Mouse 1) “Menu FvwmMenuUdisks Rectangle +$left+$top 0 -100m”)
*ButtTaskbar: (20x1, Center, Padding 0 3, Swallow “FvwmScript-Playback” “Module FvwmScript FvwmScript-Playback”)
*ButtTaskbar: (20x1, Center, Padding 0 3, Swallow “FvwmScript-Gmail” “Module FvwmScript FvwmScript-Gmail”)
*ButtTaskbar: (22x1, Center, Padding 0 3, Swallow “FvwmScript-Wifi” “Module FvwmScript FvwmScript-Wifi”)
*ButtTaskbar: (105x1, Right, Swallow “FvwmScript-Clock” “FvwmScript FvwmScript-Clock -g -30000-30000”)
*ButtTaskbar: (8x1, Action (Mouse 3) Menu MenuRoot, Action (Mouse 1) FuncShowDesktop)[/code]

Maybe there’s a more dynamic way of allowing the button that is supposed to swallow the FvwmIconMan fit to the appropriate width of different resolution monitors?

I solved this on my own. I needed an extra escape character for each escape character:

Piperead 'if [ $HOSTNAME = Willie ]; then echo *ButtTaskbar: \\(1656x1, Left, Swallow \\"IconTaskbar\\" \\"FvwmIconMan IconTaskbar\\"\\); else echo *ButtTaskbar: \\(1018x1, Left, Swallow \\"IconTaskbar\\" \\"FvwmIconMan IconTaskbar\\"\\); fi'

Still interested whether there’s a better way of doing this though.

I do this as well - have the same config file for multiple computers (with slightly different requirements).

I think Piperead is the way to go. In some cases what I do, is define extra enviromental variables with certain settings. This might be useful in situations where the commands are very long but only differ sligly. So for example in your case the only thing that differs (as far as i see) is the ‘1656x1’ and ‘1018x1’ strings - so you could do a piperead at the beginning of your config that would set some environmental variable $MY_VAR based on the HOSTNAME and later only have:

*ButtTaskbar: ($[MY_VAR], Left, Swallow “IconTaskbar” “FvwmIconMan IconTaskbar”)

… of course the drawback is that you’re creating extra (really unnecessary!) variables only so that the config looks prettier - that’s the trade-off.