You are not logged in.

#1 2019-11-21 13:15:40

zaxdan69
Member
Registered: 2016-06-04
Posts: 271

[SOLVED]Disable/enable 2nd monitor when run game

Because of a problem in a linux game, which AFAIK doesn't have option to change resolution and window/fullscreen, I want to disable the 2nd monitor when the game running and enable it again after the exit the game.
I found that I can do it using xrandr, and I managed to disable it, but I have problem when I'm trying to re-enable it afterwards. The problem is that the mode changes to mirror screen and the 1st monitor starting to have display problems and the screen is full of little squares.
Probably I'm doing something wrong when trying to enable it like this:

xrandr --output HDMI-A-0 --auto

here is xrandr' s output:

Screen 0: minimum 320 x 200, current 2720 x 1024, maximum 16384 x 16384
DVI-D-0 connected primary 1280x1024+0+0 (normal left inverted right x axis y axis) 340mm x 270mm
   1280x1024_60.00  59.89*+
   1280x1024     75.02 +  60.02
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   640x480       75.00    72.81    66.67    59.94
   720x400       70.08
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
HDMI-A-0 connected 1440x900+1280+0 (normal left inverted right x axis y axis) 410mm x 256mm
   1440x900_60.00  59.89*+
   1440x900      59.89 +  74.98
   1920x1080     60.00    59.94
   1280x1024     75.02    60.02
   1152x864      75.00
   1280x720      60.00    59.94
   1024x768      75.03    70.07    60.00
   832x624       74.55
   800x600       72.19    75.00    60.32    56.25
   720x480       60.00    59.94
   640x480       75.00    72.81    66.67    60.00    59.94
   720x400       70.08

I can fix it using xfce' s screen setting and set it right of 1st(DVI-D-0) montor, but I'd prefer to be restored automatic from game's run script:

#!/bin/bash
xrandr --output HDMI-A-0 --off
runner
xrandr --output HDMI-A-0 --auto

Last edited by zaxdan69 (2019-11-23 06:50:50)

Offline

#2 2019-11-22 20:48:54

elkami
Member
Registered: 2016-05-11
Posts: 8

Re: [SOLVED]Disable/enable 2nd monitor when run game

Hi,
My 2 cents: I use scripts for the same purpose but the scripts define all the configuration, not only the changes :

screen_game.sh :

#!/bin/sh

xrandr --output eDP1 --off --output VGA1 --off --output HDMI1 --auto 

screen_home.sh

#!/bin/sh

xrandr --output eDP1 --mode 1920x1080  --primary
xrandr --output HDMI1 --mode 2560x1080 --right-of eDP1 
xrandr --output VGA1 --mode 1920x1080 --right-of HDMI1

Offline

#3 2019-11-23 06:49:46

zaxdan69
Member
Registered: 2016-06-04
Posts: 271

Re: [SOLVED]Disable/enable 2nd monitor when run game

This was actually helpful, thanks.
I thought that I missed some parameter when  I re-enable the 2nd monitor, but I found that I just need to reconfigure the 1st monitor after I enable the 2nd. If I do it before in the script, then I have the same problem.
So, it has to be like this:

#!/bin/bash
xrandr --output HDMI-A-0 --off
runner
xrandr --output HDMI-A-0 --auto --right-of DVI-D-0
xrandr --output DVI-D-0 --auto --primary

Offline

Board footer

Powered by FluxBB