You are not logged in.

#1 2014-08-01 16:18:41

quaelgeist
Member
Registered: 2014-04-14
Posts: 17

Disable 2nd Monitor automatically while program is running?

Hello,

Some of my full screen apps are starting on the wrong monitor. I need to disable it first.

I want to disable the monitor automatically, so I need something like this:

xrandr --output DVI-I-0 --off
run_programm
xrandr --output DVI-I-0 --right-of DVI-D-0

But I want to do

"xrandr --output DVI-I-0 --right-of DVI-D-0"

when "run_programm" is finished.

as a programmer I would do something like:

xrandr --output DVI-I-0 --off
while(run_programm){

}
xrandr --output DVI-I-0 --right-of DVI-D-0

Is something like that possible or is there a better way to disable the monitor while the programm is running?

Offline

#2 2014-08-01 16:43:30

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Disable 2nd Monitor automatically while program is running?

Something like this?

xrandr --output DVI-I-0 --off
run_command
while pidof run_command; do sleep 1; done
xrandr --output DVI-I-0 --right-of DVI-D-0

Last edited by emeres (2014-08-01 16:46:59)

Offline

#3 2014-08-01 17:13:14

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: Disable 2nd Monitor automatically while program is running?

I really don't understand why your first example wouldn't work, unless run_programm forks itself to background.

anyway, this should work too:

xrandr --output DVI-I-0 --off
run_programm & pid=$!
wait $pid
xrandr --output DVI-I-0 --right-of DVI-D-0

Offline

#4 2014-08-01 17:26:21

quaelgeist
Member
Registered: 2014-04-14
Posts: 17

Re: Disable 2nd Monitor automatically while program is running?

I really don't understand why your first example wouldn't work, unless run_programm forks itself to background.
anyway, this should work too:

yea, you are right. Thanks for that advice, it worked the normal way, I just forgott the --auto command.

"xrandr --output DVI-I-0 --auto --right-of DVI-D-0"

anyway, both of your solutions are working for me thanks!

Offline

Board footer

Powered by FluxBB