2

When I play a full screen game on Ubuntu (Gnome, Kde, XFCE doesn't matter) the game decides what the monitor settings should be and then when the game is over I'm stuck with those settings. Is there an OS function that will restore my monitor settings for me automatically (like in windows) or if not, can I write a script that will save my settings to be restored easily? (like pushing a button or using a hot-key)

First monitor DVI-0 runs at 1440x900 and to it's right VGA-0 runs at 1600x900.

Okay, I've discovered that xrandr --output DVI-0 --auto --rotate normal --pos 0x0 --output VGA-0 --auto --left-of DVI-0 will set my monitors properly, however I still do not know how to make this happen easily whenever I have that "monitor bug" that happens after a full-screen app.

6
  • and I was totally going to give you credit and make a new question on how to make that a shortcut .... – Jason Mar 8 '15 at 18:17
  • It depends on the game... What do you want? A script that does it automatically per application or a keyboard short-cut that does it for you? – Fabby Mar 12 '15 at 19:20
  • Yeah, either or both. – Jason Mar 14 '15 at 2:56
  • Actually I have the hot-key setup,(figured it out) so if you could tell me how to have it script in playonlinux that would rock. Seems that windows does this out-of-the-box. I'm wondering why Linux doesn't seem to have this feature. – Jason Mar 14 '15 at 3:43
  • I need the command that starts the game engine to be able to script it. So what command do you type from the terminal to start whatever you're starting? – Fabby Mar 14 '15 at 13:12
0

Go to a terminal by pressing Ctrl+Alt+T and type the following commands:

mkdir bin

to create a binary directory in the home directory for your user that automatically will get added to the path.

cd bin
cat > SC

to change to that directory and start creating that file.

Now copy-paste the following code:

#!/bin/bash
# This script starts StarCraft as an example for automatically restoring the video
# resolution as per question https://askubuntu.com/questions/594283/

# Copyright (c) Fabby 2015

# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See the GNU General Public License for more details.
# You DID NOT receive a copy of the GNU General Public License along with this program as the license is bigger then this program.
# Therefore, see http://www.gnu.org/licenses/ for more details.
# The following line needs to be changed per game.  Example is for StarCraft
/usr/share/playonlinux/playonlinux --run "StarCraft" $1
# The following line needs to be changed per machine's individual resolution settings:
xrandr --output DVI-0 --auto --rotate normal --pos 0x0 --output VGA-0 --auto --left-of DVI-0 

and hit: Ctrl+D and then type:

chmod +x SC

Now the "program" SC is ready to be executed with 1 parameter. Close the terminal and open it again and type:

cd /path/to/SaveGames
SC szFirstCoupleOflattersOfSaveGame[Tab]

Where /path/to/SaveGames and szFirstCoupleOflattersOfSaveGame are the directory where you keep your savegames and the first couple of letters of the name of your savegame respectively followed by the Tab key to auto-complete the entire name of your savegame. (if you just type SC it will just launch StarCraft without loading any savegame...)

Then finish with Enter and smile!

The above example should be enough for any other game that you have. If you use all capitals all the time for your own games and keep he names for your "programs" short, you'll turn into a real terminal addict. ;-)

If you don't like terminal commands, there are already answers on this site to turn them into icons on your desktop or in your dash (like this one )

2
  • Thanks for that, if you wish to up your rep further and/or help me out. I'm not trying to figure out how to prevent StarCraft from Nixxing my 2nd monitor. I'll be asking a new question. I'll post the link below. – Jason Mar 15 '15 at 1:55
  • askubuntu.com/questions/596940/… – Jason Mar 15 '15 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.