gpu: Fixed duplicate intel bug.

This commit is contained in:
Dylan Araps 2018-04-09 09:51:23 +10:00
parent 4083770a6b
commit ee815f9c66

View file

@ -1284,13 +1284,21 @@ get_gpu() {
{if(!seen[a[i]]++) print a[i]}}')) {if(!seen[a[i]]++) print a[i]}}'))
IFS="$old_ifs" IFS="$old_ifs"
# Number the GPUs if more than one exists. # Remove duplicate Intel Graphics outputs.
((${#gpus[@]} > 1)) && gpu_num=1 # This fixes cases where the outputs are both
# Intel but not entirely identical.
#
# Checking the first two array elements should
# be safe since there won't be 2 intel outputs if
# there's a dedicated GPU in play.
[[ "${gpus[0]}" == *Intel* && \
"${gpus[1]}" == *Intel* ]] && \
unset -v "gpus[0]"
for gpu in "${gpus[@]}"; do for gpu in "${gpus[@]}"; do
# GPU shorthand tests. # GPU shorthand tests.
[[ "$gpu_type" == "dedicated" && "$gpu" =~ (i|I)ntel ]] ||\ [[ "$gpu_type" == "dedicated" && "$gpu" == *Intel* ]] || \
[[ "$gpu_type" == "integrated" && ! "$gpu" =~ (i|I)ntel ]] && \ [[ "$gpu_type" == "integrated" && ! "$gpu" == *Intel* ]] && \
{ unset -v gpu; continue; } { unset -v gpu; continue; }
case "$gpu" in case "$gpu" in
@ -1336,7 +1344,6 @@ get_gpu() {
fi fi
prin "${subtitle:+${subtitle}${gpu_name}}" "$gpu" prin "${subtitle:+${subtitle}${gpu_name}}" "$gpu"
((++gpu_num))
done done
return return