I'm trying to run Minecraft on my GeForce card (with Optimus, bumblebee is installed), but without having to type the command in the console every time I want to open it.
How can I configure bumblebee to always run a program with optirun by default? Will the same method work with a .jar set to launch as an executable as it would with a standard executable?
If there is an icon for the program available in the launcher and/or dash you can simply adapt the .desktop file to always use optirun. A simple way to change the respective command line is to use the
alacarte
tool.There might be more elegant ways to do it, but this is what I did:
-Open GEdit or other text editor
-Type in "optirun [or primusrun] java -jar '[directory of launcher jar, IE "/home/[user]/downloads/minecraft.jar"]"
-save the file as "Minecraft.sh", to make it an executable script
-right-click the file, go to properties > permissions > check the "allow executing this file as a program"
Now you should be able to right-click the file and click run. I know there's an option in the file manager properties to make the file execute on double-click, but I'm on Kubuntu, and it's a bit different. I don't remember how to change that option it on regular Ubuntu, sorry.
Also, protip, if you're not already using it, use Primusrun instead of Optirun with bumblebee. if primusrun isn't installed, it's just "sudo apt-get install primus". I've noticed some pretty definite speed boosts with it.
I know this question is old, but I'd like to give my own contribution as well. This is valid for any distribution, not only Ubuntu.
1. Create a command alias
So then you will be able to run the application from terminal or everywhere else that references it. This is the most generalized possible solution for the problem. For my example, I'll be editing the command
obs
to always run withprimusrun
.Run this commands:
Now when you run
obs
in the terminal, it will callprimusrun obs
instead.If then you want to run the application without
primusrun
for whatever reason, you'll need to make an absolute call to its executable. That's easy:This will work as well for the desktop launcher if it calls for the relative command
obs
too, but if the launcher calls for the absolute path, like/usr/bin/obs
, then you'll need to go to step 2 as well.2. Edit the launcher
Find where the
.desktop
file is located. If it is a userspace application (like Wine applications), it should be under~/.local/share/applications
, otherwise it should be under/usr/share/applications
. Find the.desktop
file for your application (this can be somewhat tricky, as some file managers will display the application title instead of the actual file name) and edit it with you favorite text editor:Find the line
Exec=
and addprimusrun
oroptirun
before the command.Save and quit.
Bear in mind that if the launcher calls for the relative command (just
obs
instead of/usr/bin/obs
) this will effectivelly cause the desktop launcher to run the command with twoprimusrun
likeprimusrun primusrun obs
, but this won't cause any issue.