Automatically Switch Between Monitor Inputs
We geeks are lazy. Manually switching between monitor inputs can be a pain if you have to navigate the monitor’s menu to do so. If you’re lucky enough to have a monitor with a dedicated input switch button, constantly switching between inputs is a good way to break that switch on a cheap monitor.
Almost all monitors with multiple inputs will auto-switch to an input that has a signal if the current input’s signal goes away. This can be taken advantage of if you have the tools to force the monitor signal to turn off. Then switching inputs is easy.
- Make sure the computer you want to switch to is awake.
- Turn off the monitor signal on the computer you are currently using.
FOR WINDOWS: Download NirCmd and use nircmd.exe cmdwait 500 monitor off
. For the most convenience, you can set a desktop shortcut and/or use the Shortcut Key property to call the command.
FOR LINUX: Copy this script and save it to /usr/bin/monitoroff
. You can save it anywhere and name it anything, but /usr/bin
will allow all users to run the command (chmod 755
) and the name monitoroff
coincides with the poweroff
script on most Linux distros. (Credit.)
#!/bin/bash ################################################### # Check if X is running or not, turn off monitor, # # wait for a key press and turn it on again. # ################################################### grep_result_file=$PWD'/x_running' # Check if X is running. ps -e | grep -e "\bX\b" > $grep_result_file ps -e | grep -e "\bxorg\b" >> $grep_result_file ps -e | grep -e "\bxserver\b" >> $grep_result_file ## If you want to check result file, uncomment following lines. #echo "===== $grep_result_file - begin =====" #cat $grep_result_file #echo "===== $grep_result_file - end =====" if [ ! -s $grep_result_file ] || [[ $(tty) =~ tty ]] || [[ $(tty) =~ vc ]]; then echo 'Detected X not runnig or you are at console...' if [ $UID -ne 0 ]; then echo 'You need super user privileges to run this script at console.' echo 'Rerun as super user or start X and run from a terminal.' exit 0 fi turn_off='vbetool dpms off' turn_on='vbetool dpms on' else echo 'Detected X running...' turn_off='xset dpms force off' fi echo 'Turning off monitor...' $turn_off echo 'Waiting for a key press...' read -n1 -s echo 'Turning on monitor...' $turn_on rm $grep_result_file echo 'Finished: monitor_off'
gary 6:32 pm on June 24, 2012 Permalink |
This doesn’t work at all for me, even though my monitor is set up for auto-scan/auto switch source. The monitor has an OSD where I can manually switch sources, and when I “put it to sleep” using nircmd, the monitor is paralyzed–I can’t even access the OSD unless I wake it by wiggling the mouse. So doing this is not the equivalent of yanking the cable, which WILL which switch the input source if the other computer is providing a signal.
BrainwreckedTech 11:34 am on June 29, 2012 Permalink |
This is interesting. Have you tried playing with the BIOS settings for the settings concerning monitor turn-off or power savings? I’m on vacation right now so the names might be off, but there’s usually a few like DPMS, V-Blank, Black Screen, and such. I can see auto-switch failing on the black screen method, but freezing the OSD might be indicative of using a power-off method that the monitor doesn’t really support.
Could also be that your monitor has faulty auto-switch capabilities. The ideal is that the monitor would skip over any input that doesn’t have an active imaging signal. What it could be doing is counting any closed circuit as a signal. This is easy to test for: With two PCs on, turn one off without unplugging any cables. If a switch-over occurs, it might be a BIOS setting. If it does not, the auto-switch is cheap closed/open circuit detection.
Nura 10:49 am on August 16, 2012 Permalink |
Works perfectly 🙂 Thanks.
Just a additional query though. Do you know how the “nircmd.exe cmdwait 500 monitor off” can be tweaked such that one can switch off a chosen monitor when two monitors are connected to a machine :), like say for instance want to switch of the left monitor (which is identified as Display num 1 by windows) 🙂
thanks again.
regards
BrainwreckedTech 11:58 pm on August 18, 2012 Permalink |
The decision to turn monitors off is based on the lack of keyboard and mouse activity, and to monitor that efficiently requires lower-level access (monitoring port activity) that precludes monitor information.
There is one semi-solution, though. Win+P will allow you to change multiple-monitor mode, including switching back to single-monitor mode.
BoseRoHS 7:25 am on January 14, 2014 Permalink |
Though, how can you avoid the Win+P method? As Nura inquired… how is it possible to switch off the second monitor so that one can control and view the other computer connected to the other input?
With dual monitors and Win+P the custom display (ie. tabs, desktop icons, etc) settings on the main computer will all revert to the main monitor.
I’m using Microsoft Garage to control both PC’s via mouse and keyboard, but unable to control the second monitors input, unless I switch the physical switch on the monitor or an application like mControl from Entech (software is buggy and 21-day trial expired 2 days after install). So, now, I’m looking for an alternative.
BrainwreckedTech 7:57 pm on January 14, 2014 Permalink |
The last hope would be Displayfusion, which claims to “Enable/disable monitors.” Sound more like “Disable Display” than “Put Display To Sleep,” though.
Ncrmd, Ultrmon, EnTech, and Displayfusion are the only tricks I know of.
Handcrafter 6:53 pm on April 17, 2013 Permalink |
Thank You for the Win+P tip. Waiting for the auto switch on my aoc monitor was frustrating…
Handcrafter
Room 7:24 pm on August 6, 2014 Permalink |
Thank you,” nircmd.exe monitor off” works perfectly for me.
This is my setup:
I have two monitors with dual inputs, and two PC’s with dual inputs. Both PC’s are connected to each monitor so I can run dual screens on each PC.
If both machines are ON at the same time, I wanted to switch to each machine in dual monitor mode seamlessly without having to fiddle around with the source button or OSD menu on each monitor.
This command works a charm! Just create the shortcut with the command and double click. WAIT and both monitors will switch over to the other machine, when you want to switch back just double click on the shortcut on the other PC, WAIT and it will switch back! perfect just what I was looking for.
I note, it’s very important that you WAIT, if you click or type during the switch over you’ll find one monitor will switch while the other one won’t. Just wait without touching anything and it will switch over.
Also, both my monitors have AUTO source enabled, if yours doesn’t this might not work for you.
Thor Mengkheang 6:41 am on May 7, 2015 Permalink |
the windows one work perfectly but do you have a script for mac?