There are two ways to act on another layer that is not active
1. use layer -o command, like
layer -o 2 {layer.y.showlabels=0;};
2. In Yuki's example, you can skip the window name if you are operating on the active window, so
range layer2nd = 2!;
Layer2nd.y.showLabels=0;
CP