You are not logged in.

#1 2016-04-09 14:50:49

hooya
Member
Registered: 2011-10-09
Posts: 99

[SOLVED] Looking for a quick way to toggle a secondary monitor ...

I have an Nvidia video card and use the closed-source proprietary drivers (nvidia 361.28-4 at the time of this writing). I have two monitors, both set up as Display 0 through the nvidia-settings utility. There are some applications (notably some games in wine) that do not play nice with a multi-monitor setup this way, and so to use them I use nvidia-settings to disable the secondary monitor. When I'm done, I re-enable the secondary monitor. In Gnome 3 the procedure is:
1. Open nvidia-settings
2. click x server display configuration
3. select secondary monitor
4. dropdown menu in configuration set to new setting (X screen 0 or disabled)
5. Click Apply
6. click OK to the prompt
7. click quit
8. click "really quit" at the prompt

It works just fine, but the process to do this is a number of clicks and it's getting tedious. Is there a simple script/command that I can create that would toggle the secondary monitor on/off. I'd be OK with two separate scripts to do this (one to enable, one to disable).

I've looked at the wiki and there's a lot of information there on setting up sometimes very complicated configs for multihead setup, but nothing about simply enable/disable a secondary monitor on the fly as needed. Maybe I missed a wiki entry that would have this information.

Any ideas?

Last edited by hooya (2016-04-09 15:56:59)

Offline

#2 2016-04-09 15:14:01

ArttuH5N1
Member
From: Finland
Registered: 2016-03-10
Posts: 5

Re: [SOLVED] Looking for a quick way to toggle a secondary monitor ...

I wonder if making a simple xrandr script would work in multihead setup. I have the following script setup to run on W-§ (I'm changing between two displays, this is the one to disable one. I have another to do the opposite, disabling DVI and enabling HDMI):

#!/bin/bash
# Display toggle script

xrandr -q &

xrandr --output DVI-0 --primary --mode 1920x1080 --pos 0x0 --output HDMI-0 --off &

(sleep 2s && nitrogen --restore)

(I'm not sure if the first line is necessary. I added it recently since I noticed that sometimes I couldn't change from one display to another without "refreshing" xrandr first. But I haven't honestly looked too much into it. The last line isn't of course necessary with gnome.)

Now the issue would be how your displays are named/recognized. I'm sure you've already looked this over, but at least there seem to be commands to reactivate multihead it, after you're done gaming.

https://wiki.archlinux.org/index.php/Multihead#RandR

This comment is just something you might look into, rather than a comprehensive answer, since I'm a noob myself. Hopefully someone more knowledgeable is able to come in and give better advice.

Last edited by ArttuH5N1 (2016-04-09 15:15:26)

Offline

#3 2016-04-09 15:56:26

hooya
Member
Registered: 2011-10-09
Posts: 99

Re: [SOLVED] Looking for a quick way to toggle a secondary monitor ...

Ah, that does help. xrandr lines looked more complicated at first than I thought.

I can use console to turn on and off my secondary as such:

off:

xrandr --output DVI-D-1 --off

That turns off my second display

xrandr --output DVI-D-1 --auto --right-of HDMI-0

Turns it back on with the default resolution just fine. I don't need to specify any more than that. Now to make my keyboard shortcuts!

Last edited by hooya (2016-04-09 16:22:41)

Offline

Board footer

Powered by FluxBB