Run a Command-line Program with an Environment Variable
Solution 1:
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
.
Solution 2:
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.