Ubuntu – Run a Command-line Program with an Environment Variable

command lineenvironment-variablesgraphics

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.

Best Answer

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.

Related Question