Select background using batchPlay

Heya,

Using Alchemist I created the underlaying command, which selected the background for me.
This is required to align the item I’m copying into the document to the centre.

But I noticed, Photoshop also translated default layer names when using another language…

To counter that, I thought I could rename the background layer, but this caused it to not be the background anymore, and it seems that has caused other issues with the rest of the script.

async function selectCommand() {
    return await action.batchPlay(
        [

            {
                _obj: "select",
                _target: [
                    {
                        _ref: "layer",
                        _name: "Background"
                    }
                ],
                selectionModifier: {
                    _enum: "selectionModifierType",
                    _value: "addToSelection"
                },
            }
        ],
        {
            modalBehavior: "execute"
        }
    );
}

So to return to the original issue, I wanna go back to what I had before, but then properly select the background regardless of localisation.

So is there a way to select the background, like above, but without using the name?

You could get the background layer id with:

const backgroundLayerID = app.activeDocument.backgroundLayer.id;

and then select the layer by id with:

async function selectCommand(id) {
    return await action.batchPlay(
        [

            {
                _obj: "select",
                _target: [
                    {
                        _ref: "layer",
                        _id: id
                    }
                ],
            }
        ],
        {}
    );
}

Or the easiest way without batchPlay:

app.activeDocument.backgroundLayer.selected = true;

Or the easiest way without batchPlay:

app.activeDocument.backgroundLayer.selected = true;

I was overthinking this LOL