While you're here, please consider supporting GamingOnLinux on:
Reward Tiers:
Patreon. Plain Donations:
PayPal.
This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!
You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Reward Tiers:
This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!
You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register
- Nexus Mods retire their in-development cross-platform app to focus back on Vortex
- Steam Frame and Steam Machine will be another good boost for Flatpaks and desktop Linux overall too
- Canonical call for testing their Steam gaming Snap for Arm Linux
- Windows compatibility layer Wine 11 arrives bringing masses of improvements to Linux
- European Commission gathering feedback on the importance of open source
- > See more over 30 days here
- Welcome back to the GamingOnLinux Forum
- Liam Dawe - A New Game Screenshots Thread
- JohnLambrechts - Will you buy the new Steam Machine?
- mr-victory - Game recommendation?
- JSVRamirez - Weekend Players' Club 2026-01-09
- Minoscereb - See more posts
How to setup OpenMW for modern Morrowind on Linux / SteamOS and Steam Deck
How to install Hollow Knight: Silksong mods on Linux, SteamOS and Steam Deck
On the telegram chat group somebody asked for a simple solution to turning on/off one of two screens.
This is especially useful for Linux gamers because Steam games mostly start on your main screen. If you want games to run on your TV or a different screen, it's a little bit of a hassle to manually switch which one is your main screen. This solution makes that much easier.
So I decided to write a little explanation on how it could be done using xrandr.
For a small description on xrandr I'll quote the man page I'm doing this on my own desktop that has 2 monitors a 1080p and an old vga 1280x1024 one. These are the ones I'm using in the example. adapt to your own needs
I'm using a terminal to execute these commands so fire up xterm/lxterm/xfce-terminal/gterm/terminator/etc/etc.
1) Identify screens
xrandr -qThis returns 2 monitors for me
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384VGA-0 connected (normal left inverted right x axis y axis)
1280x1024 60.02 + 75.02
1024x768 75.03 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
640x480 75.00 72.81 59.94
DVI-D-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 368mm x 207mm
1920x1080 60.00*+
1680x1050 59.95
1600x900 60.00
1440x900 59.89
1280x1024 75.02 60.02
1280x960 60.00
1280x800 59.81
1280x720 60.00
1152x864 60.00
1024x768 75.03 70.07 60.00
800x600 75.00 72.19 60.32 56.25
640x480 75.00 72.81 59.94
In my examples I shall use DVI-D-0 and VGA-0, replace them with your own names found.
2) Test with xrandr
So now that we know our monitors , let's try turning on the second one and turning off the first one. That way we don't have to work blind.
xrandr --output VGA-0 --autoand turn off the first monitor
xrandr --output DVI-D-0 --offAnd now let's reverse the process
xrandr --output DVI-D-0 --autoxrandr --output VGA-0 --off
3) Profit!
The previous steps worked perfectly for me. I decided to create a script that would automate this for me.
3.1) example script
#!/bin/bash
#Either use the hardcoded stuff below
#replace these values with your own!!!
#MON1=DVI-D-0
#MON2=VGA-0
#OR try to get the first and last connected monitor
MON1=`xrandr -q|grep \ connected|awk '{print $1}'|head -n1`
MON2=`xrandr -q|grep \ connected|awk '{print $1}'|tail -n1`
MON1_CURRENT=`xrandr --listactivemonitors| awk '{ print $4 }'| grep ${MON1}`
# 0 we want the 2nd monitor to turn on
# 1 we want the 1st monitor to turn on
STATE=0
# ASSUMPTION!
# if MON1_CURRENT is empty were probably using the secondary monitor
if [ "x$MON1_CURRENT" == "x" ]
then
STATE=1
fi
if [ $STATE -eq 0 ]
then
#turn of MON1 and turn on MON2
xrandr --output $MON1 --off
xrandr --output $MON2 --auto
else
#turn of MON2 and turn on MON1
xrandr --output $MON2 --off
xrandr --output $MON1 --auto
fi
To turn this into a script for yourself you can copy/paste the code above into your favourite text-editor and save it with the name of your choice. I chose togglescreen.sh because that's what it does and it's a shell-script.
mark the file as being executable using your filemanager or using the terminal.
chmod +x owgodwheredidIsavethedamnthingthistimeI saved it in my homefolder so for me it's
chmod +x togglescreen.sh3.2) take a testdrive
Either run it from your filemanager, probably using a doubleclick, or alternatively
/insomepath/where/i/saved/it/owgodwheredidIsavethedamnthingthistimeagain for me that translates into
~/togglescreen.shRepeat running the scripts to revert to the old state.
As a sidenote you can adapt the commands to do other stuff than just turning monitors on and off. Do take the time to read the manpage for xrandr.
To read the manpage from the terminal
man xrandrFor people using nvidia proprietary drivers this link might help prevent tearing after switching screens.
I hope this helps a few people. Any suggestions or questions, add them below.
Regards,
Ysblokje
PS: thanks goes to Jan for proofreading and some suggestions
Also it's my example script. You're free to modify it to your own needs.