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:
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.
Bookmarks