8

I am using the mpv media player to play my videos. I have a laptop with hybrid graphics so in order to use the discrete GPU I must use DRI_PRIME=1 mpv video.mp4 whenever I want to run mpv with the discrete GPU. However, typing DRI_PRIME=1 everytime is quite annoying, so I was wondering if there is a way to make it so everytime I run mpv DRI_PRIME=1 is always used.

2 Answers 2

20

If you want only mpv to be affected, just alias it:

alias mpv='DRI_PRIME=1 mpv'

You can add this to ~/.bashrc or ~/.bash_aliases.

12

Place that variable into your ~/.bashrc file like so:

export DRI_PRIME=1

and run source ~/.bashrc. After that this variable will be always in your shell's environment.

NOTE: exporting variables allows them to be passed to each and every program you run from shell. For the most part this should not matter, unless you have two programs that expect different value for your variable ( in this case DRI_PRIME ). If you intentionally want two programs have different value of DRI_PRIME, use muru's answer.

3
  • 1
    You beat me to it by 5 seconds :P Jun 7, 2017 at 1:45
  • maybe add a note that every program run from the command line will use the discrete card which may or may not be what you want
    – cat
    Jun 7, 2017 at 17:25
  • @cat already added that Jun 7, 2017 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .