Author Topic: Squirrel script to change display.  (Read 8600 times)

TheFirstAv3nger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Squirrel script to change display.
« on: February 04, 2017, 06:01:38 AM »
Hello, I've been reading a bit about the squirrel language and would like to make a script to change the display.
I've read documentation and there is a function called  "fe.set_display()"
If anyone could help me on writing a script to do so I'd greatly appreciate it.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Squirrel script to change display.
« Reply #1 on: February 04, 2017, 07:36:00 AM »
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:

Code: [Select]
//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")

TheFirstAv3nger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Squirrel script to change display.
« Reply #2 on: February 04, 2017, 04:11:33 PM »
Thanks for the help. One more thing. How would I go about running this script from the terminal to get the index and name of the displays?

TheFirstAv3nger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Squirrel script to change display.
« Reply #3 on: February 09, 2017, 06:24:10 PM »
Anybody?

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Squirrel script to change display.
« Reply #4 on: February 09, 2017, 08:16:32 PM »
You should just need to change AM to run in windowed mode and you can see the prompt output...

TheFirstAv3nger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Squirrel script to change display.
« Reply #5 on: February 13, 2017, 04:47:37 PM »
You should just need to change AM to run in windowed mode and you can see the prompt output...

I'm sorry I thought I put that I was on a raspberry pi, running windowed doesnt change anything. I would jut like to run a script from terminal to get the display index or name, then another separate script to switch to said display from a terminal or ssh.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Squirrel script to change display.
« Reply #6 on: February 13, 2017, 06:42:27 PM »
Well I would say it's better to design on something else and copy your layout over.. but I'm sure there is a way to pipe output to a logfile or launch it in another terminal and switch back and forth? My linux is a bit rusty.. regardless, unless you are running it in X it'll be a pain to see debug output and the UI