fe.displays is an array containing a list of your displays, so you can check len() to see how many there are... each of those entries you can use .name to find out the name.
The issue I noticed when trying to use set_display is you will get stuck in a loop reloading the layout unless you check that you are loading a different display than is already loaded - here is two functions that load based on index or display name:
//find out about the displays
print(fe.displays.len() + " displays\n")
foreach(idx, display in fe.displays )
print( idx + ": " + display.name + "\n")
//load based on display index
function load_display(idx) {
if ( fe.list.display_index != idx ) fe.set_display(idx)
}
//load based on display name
function load_display_name(name) {
foreach( idx, display in fe.displays )
if ( name == fe.displays[idx].name && name != fe.displays[fe.list.display_index].name ) fe.set_display(idx)
}
load_display_name("mame")