Setting up Psychtoolbox on Linux (Debian)- two screens

I thought I would include the guide I wrote after setting up Psychtoolbox on Linux in our lab. I am by no means an expert, but this procedure worked well for me so I thought it may be useful to others.

Two-screen Linux (Debian) set-up guide for Psychtoolbox

Setting up Psychtoolbox

  • If Psychtoolbox was downloaded from NeuroDebian instead of via DownloadPscyhtoolbox or SetupPsychtoolbox
    • Run PsychLinuxConfiguration within Psychtoolbox once

Secondary screen only for experimental stimuli

  • This is the setup I have arrived at for using the second screen purely to present stimulus- using this setup the second screen becomes almost useless for other tasks as it is almost entirely independent of the first screen.

Use Psychtoolbox to create an Xscreen setup

  • Run the command XOrgConfCreator within Matlab to create a file for this set-up, this will guide you through the setup process by answering some questions.
    • For the setup I used, the questions and answers were along the lines of:
      • Do you want single or multiple display set up: multiple
      • Which display output do you want to be assigned to Screen0: 1
      • Do you want to assign the other display output to a Screen: yes
      • Which display output do you want to be assigned to Screen1: 2
      • Do you want to configure advanced settings: no
    • This should be a fairly intuitive set-up, there is also a help page for it.
    • The system I used had problems saving this file, although it did not generate an error: so I changed the save location to the home folder then moved it to the correct location (which for me was /~/.Psychtoolbox/XorgConfs/ or something similar- this is the PsychtoolboxConfigDir but it can be [changed](Psychtoolbox-3 - XOrgConfSelector))
      • additionally, by default files and folders with . in-front are hidden- there should be some way to show hidden files in the file explorer
  • Once this file is created and added into the correct location you should be able to run XOrgConfSelector within Matlab and it should display the file you just made as an option, which you can then select and log out and back in/ reboot.
  • This should have copied and appropriately renamed the new .conf file you made to the correct location (`/etc/X11/xorg.conf.d/)
  • If you have opted for the multiscreen set-up as I have, and everything has worked correctly, you should now have a second screen that is black, and if you drag your mouse over to it (automatically it is set RightOf your default screen) it should appear as a black ‘x’ with white outline. You won’t be able to drag any programs over there or anything of the sort- however Psychtoolbox should now recognise this as a different screen- with a number corresponding to whatever you chose during XOrgConfCreator set-up.

Reverting to different settings

  • The above settings you configured should stay that way until you change them.
  • There are a couple of ways of changing it.
  • Firstly and probably most sensibly, you can re-run XOrgConfCreator and generate a new file for a single screen set-up or any variation upon the set-up. This will then be stored alongside the file you previously made, and they can be selected back and forth using XOrgConfSelector- rebooting/ logging in and out each time.
  • The other solution is to delete the file in /etc/X11/xorg.conf.d/ , this shouldn’t be a problem for loosing data, as the original copy of your file is stored in /~/.Psychtoolbox/X11/xorg.conf.d/. Removing this will revert to the default set-up when you reboot/ login and out.

Changing settings on the secondary screen

  • The above will work for anything where the default screen settings are appropriate.
  • However, if you want to change the settings of the second screen, you may have noticed that they do not show up in the display settings, or via xrandr
  • This is because they are separate Xscreens now, and is nothing to worry about.
  • Editing the settings is now slightly more complicated, but only slightly.
  • from here-on any commands referred to are to be input into a terminal- not Matlab

Changing to another of the already existing modes

  • They key element to using the other screen is running the commands with DISPLAY=:0.1 in front of them. This selects screen 1.
  • So to see the list of available modes for your secondary display, open a terminal on your primary display and use the command DISPLAY=:0.1 xrandr, this should output all the randr settings available for your secondary display, along with its name. For reference, and the sake of further examples, the name of my secondary display output was DisplayPort-1.
    • If one of the existing modes matches your desired output, you can select it using DISPLAY=:0.1 xrandr --output displayoutputname -- mode widthxheight_Hz
      • replace displayoutputname with the name of your display output, which was reported by DISPLAY=:0.1 xrandr
      • replace width with the width in pixels
      • replace height with the height in pixels
      • replace Hz with the refresh rate
      • for example, my desired output command looked like this: DISPLAY=:0.1 xrandr --output DisplayPort-1 --mode 1024x768_100 and outputted at 1024x768 pixels at 100Hz.
        • (although it actual output at 99.97Hz)
  • If the list of supported modes don’t include your desired mode, first check your desired mode is within the capabilities of the screen, then see below.

Creating a new mode

  • It is possible to create a mode for the screen that doesn’t currently show as supported for whatever reason.
  • Step one is to run DISPLAY=:0.1 cvt width height Hz
    • replace width with the width in pixels
    • replace height with the height in pixels
    • replace Hz with the refresh rate
    • for example my command looked like this: DISPLAY=:0.1 cvt 1024 768 100
  • This should output a string of numbers ending in hsync vsync which you will need
  • Create the new mode using DISPLAY=:0.1 xrandr --newmode "widthxheight_Hz" then the string of numbers again replacing the relevant parts.
    • For example mine looked like this: DISPLAY=:0.1 xrandr --newmode "1024x768_100" 112.25 1024 1096 1200 1376 768 771 775 816 -hsync +vsync
  • You then need to add this mode as a possible mode for the desired output using DISPLAY=:0.1 xrandr --addmode displayoutputname "widthxheight_Hz, again replacing the relevant parts
    • mine looked like this: DISPLAY=:0.1 xrandr --addmode DisplayPort-1 "1024x768_100"
  • And now set this as the output using DISPLAY=:0.1 xrandr --output displayoutputname --mode widthxheight_Hz
    • e.g. DISPLAY=:0.1 xrandr --output DisplayPort-1 --mode 1024x768_100
  • Your secondary display should now be outputting at the desired spec.
  • However, this will reset every time you reboot.

Saving your new mode

  • There is no way to save the new mode perse, you must instead configure the 3 commands you just used (–newmode, --addmode, and --output) to run at start-up.
  • There are several ways to do this, the way I used was to download autorandr
    • sudo apt install autorandr
    • save the current configuration autorandr --save default
    • enable run at startup sudo systemctl enable autorandr
  • You can check if this was effective by rebooting then running DISPLAY=:0.1 xrandr and the settings you want should be visible and have an asterisk by them if they are currently in use.
  • I also added the correct settings to the Psychtoolbox copy of the .conf file, and the ran XOrgConfSelector again to copy this into the correct destination folder. I am not sure whether this step is necessary.
    • Here’s what my file looked like afterwards
# Auto generated xorg.conf - Created by Psychtoolbox XOrgConfCreator.

Section "ServerLayout"
  Identifier    "PTB-Hydra"
  Screen 0      "Screen0" 0 0
  Screen 1      "Screen1" LeftOf "Screen0"
EndSection

Section "Monitor"
  Identifier    "eDP"
EndSection

Section "Monitor"
  Identifier    "DisplayPort-1"
  Modeline "1024x768_100" 112.25 1024 1096 1200 1376 768 771 775 816 -hsync +vsync
  Option "PreferredMode" "1024x768_100"
EndSection

Section "Device"
  Identifier  "Card0"
  Driver      "amdgpu"
  Option      "ZaphodHeads" "eDP"
  Option      "Monitor-eDP" "eDP"
  Screen 0
EndSection

Section "Device"
  Identifier  "Card1"
  Driver      "amdgpu"
  Option      "ZaphodHeads" "DisplayPort-1"
  Option      "Monitor-DisplayPort-1" "DisplayPort-1"
  Screen 1
EndSection

Section "Screen"
  Identifier    "Screen0"
  Device        "Card0"
  Monitor       "eDP"
EndSection

Section "Screen"
  Identifier    "Screen1"
  Device        "Card1"
  Monitor       "DisplayPort-1"
  Subsection "Display"
  	Modes "1024x768_100"
  EndSubSection
EndSection