Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: HOWTO: Switch between a fullscreen game and your regular desktop

  1. #1
    Join Date
    Mar 2007
    Beans
    108

    HOWTO: Switch between a fullscreen game and your regular desktop

    Yay, gaming on Ubuntu!

    Unfortunately, you know the problem: when a game is fullscreen, ALT+TAB often does not work, or otherwise makes your system go a bit ... crazy. In such cases, the only way to safely switch out of your game is to quit it. Annoying!

    Well, a terrific solution, which I will guide you to here, is to run the game on a separate desktop (an X server). As a side effect, the gaming desktop will run without Compiz, so you might get a bit better graphics performance on it. Win, win, win!

    GAME LAUNCHER!

    Because I'm awesome, I wrote a very small and handy application that does all this for you. It's called ... Game Launcher!

    Game Launcher shows you all the applications you have installed, and lets you launch them in the separate gaming desktop. It also lets you mark games to always launch in the gaming desktop, even if you don't launch them from Game Launcher. It even lets you bookmark a few favorite games, so you don't have to scroll through the long list...

    To install Game Launcher, open a terminal:
    Code:
    sudo add-apt-repository ppa:emblem-parade/gamelauncher
    sudo apt-get update
    sudo apt-get install gamelauncher
    You can now launch it from your dash. Game Launcher! Win, win, win!

    The full source code is available here. Please report bugs here.

    If you don't want to use Game Launcher, or would rather learn how it works, follow the steps below. They do exactly what Game Launher does manually. I've tried to make this guide as easy as possible for novices, and it should only take you a few minutes to go through. All steps are reversible and none will compromise your system.

    INITIAL SETUP

    We will first need to enable two specific permissions.

    First, let's give your user permission to use audio even on another desktop. Open a terminal:
    Code:
    sudo usermod -a -G audio username
    ...where "username" is your Ubuntu username. You need to logout/login for this to take effect, so do it now.

    Second, let's give you (and all users) persmission to start another desktop. Open a terminal again:
    Code:
    gksudo gedit /etc/X11/Xwrapper.config
    In this text file, you'll see this row:
    Code:
    allowed_users=console
    Replace it with this:
    Code:
    allowed_users=anybody
    Save the file and exit gedit. (No need to logout, the change took place immediately this time.)

    OK, you now have permissions to run a new desktop with full sound.

    LAUNCHING THE GAME

    Now, find the command you usually need to run your game.

    Often the command is just the name of the game, but sometimes it's a bit different or has a directory prefix. To find it, you can look in the game's launcher. The launchers are in your "/usr/share/applications/" directory. Browse this directory with the file browser, right click on the game's launcher, and choose "Properties." You will see a "Command" entry. That's it! For example, I'm playing Super Meat Boy, and the command is:
    Code:
    /opt/supermeatboy/SuperMeatBoy
    To run the game in its own desktop, in your terminal wrap the above command with "/usr/bin/xinit" in front and "-- :1" after it. For my example, it would be so:
    Code:
    /usr/bin/xinit /opt/supermeatboy/SuperMeatBoy -- :1
    (Yes, those are two dashes.)

    PLAYING THE GAME

    To switch to your regular desktop: CTRL+ALT+F7

    To switch to your gaming desktop: CTRL+ALT+F8

    Easy, clean and neat. Better in some ways than ALT+TAB. It would be nice if there was a way in Ubuntu to configure this for all applications, no?

    Notes:

    1) The game does not automatically pause when you switch to the regular desktop. Likewise, applications on the regular desktop will continue to run.

    2) You will not get desktop notifications (for instant messages, emails, etc.) on the gaming desktop. But, you will hear sounds from all runnning applications. So, if you want to make sure that you are notified of events while playing, make sure to configure obvious sounds that won't be easily confused with noises happening in the game. (Did I just kill a zombie, or is that an email from my mom?)

    3) You're only able to run one game at the same time with this method. But that's OK, you should finish your dinner before you get dessert.

    4) Do not use "sudo" to start the game! If you do, xinit will set root permissions on the ".Xauthority" file in your user's home directory, making it impossible for you to start your regular desktop in the future (you won't be able to log in to Ubuntu). If this somehow happens to you by mistake, just delete the ".Xauthority" file, and it will be regenerated using standard permissions next time you login.

    5) Instead of CTRL+ALT+# you can use "sudo chvt #".

    MAKE IT PERMANENT

    If all works well, you can also change the launcher for the game so it will always launch in a separate desktop. You need administrative permissions for this, so in a terminal let's open a privileged file browser:
    Code:
    gksudo nautilus
    WARNING: IT'S REALLY EASY TO CAUSE SERIOUS DAMAGE WITH A PRIVILEGED FILE BROWSER. USING IT, YOU CAN DELETE/MOVE IMPORTANT SYSTEM FILES AND BREAK YOUR OPERATING SYSTEM. MAKE SURE TO CLOSE IT AS SOON AS YOU ARE DONE WITH THIS GUIDE.

    Again, find the launcher for your game, right click it, and choose "Properties." You can now change the "Command" entry to be the wrapped command above. (Changing it is only possible because we are using a privileged file browser.)

    Close the properties and make sure to close the file browser.

    You might need to logout/login for the Unity Dash/Launcher to properly pick up your changes. From now on your game will always launch in the gaming desktop.

    Note: even though you can launch the game from the Unity Launcher, you will not be able to switch to the game using the Unity Launcher, nor will the Launcher show the game icon as lit when the game is running. You can only switch to the game using CTRL+ALT+F8.

    Enjoy!

    Tested on Ubuntu 12.10 AMD64.
    Last edited by Emblem Parade; January 9th, 2013 at 10:40 AM.

  2. #2
    Join Date
    Apr 2006
    Beans
    50
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Thank you! Will be using this method from now on.


    One correction, though:

    Quote Originally Posted by Emblem Parade View Post
    First, let's give your user permission to use audio even on another desktop. Open a terminal:
    Code:
    sudo useradd -G audio username
    ...where "username" is your Ubuntu username. You need to logout/login for this to take effect, so do it now.

    The useradd command creates a new user and adds it to the group. If you run the command you posted you'll get an error. Command usermod must be used instead:

    Code:
    sudo usermod -G audio username

  3. #3
    Join Date
    Mar 2007
    Beans
    108

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Oops, thanks!

  4. #4
    Join Date
    Apr 2006
    Beans
    50
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    BEWARE!!!

    The command I suggested is wrong! if you execute it as I posted, your user will get removed from the administration group!

    Instead you should execute it with the -a option:

    Code:
    sudo usermod -a -G audio username

    Sorry for any trouble I might've caused...

  5. #5
    Join Date
    Apr 2006
    Beans
    50
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Alternatively one can also use this other command, which does the same:

    Code:
    sudo gpasswd -a username audio



    PS: I've been a victim of my first tip and I lost my administration privileges. Here's a quick guide for anyone that might have been (unintentionally ) tricked by me:

    1-Reboot your system

    2-At the GRUB screen, press E

    3-Edit the line that loads the kernel and specifies its parameters (the one that begins with linux) and append single at the end

    4-Press F10 to boot and you'll end at a root console

    5-Give yourself back the permissions you lost:

    Code:
    gpasswd -a username adm
    gpasswd -a username sudo
    gpasswd -a username lpadmin
    gpasswd -a username sambashare
    6-Reboot and everything should be back to normal

  6. #6
    Join Date
    Mar 2007
    Beans
    108

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Fixed again! Thanks for the extra info.

  7. #7
    Join Date
    May 2012
    Beans
    9

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Nice!

    Seems like it should be stickied.

  8. #8
    Join Date
    Mar 2007
    Beans
    108

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    I agree! I've considered writing a nice GUI utility to do this for you. If there's a lot of interest, I'll give it a whirl.

  9. #9
    Join Date
    Mar 2007
    Beans
    108

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Because I'm awesome, I went ahead and wrote the app. Game Launcher! I update the main thread post with installation instructions.

  10. #10
    Join Date
    May 2008
    Location
    Chicken Farm
    Beans
    410
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Switch between a fullscreen game and your regular desktop

    Love the idea !
    Unfortunately it doesn't work on ubuntu 12.04 LTS 64bit
    I press on the "enable gaming desktop" and insert admin pass and nothing happens, tried maybe 8 times.
    Also pressed add,tried to check the boxes besides the app names and slide down the list of all available apps, but none of these 3 worked.

    Edit:
    Have a few questions, does the audio from the main desktop xserver carry to the game xserver ? I think an option of that nature is useful, since sometimes i can be playing on a pub and don't mind others highlighting me on xchat, while other times i can be playing a duel and want to focus entirely on the game.
    Last edited by cristo-father; February 21st, 2013 at 06:46 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •