#!/bin/bash
# -*- coding: utf-8; indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
# vim:fileencodings=utf-8:expandtab:tabstop=4:shiftwidth=4:softtabstop=4

ROOTID=`lspci -nnv | grep -A2 "Host bridge" | grep "Subsystem" | head -n 1 | sed 's/.*:\([[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]\)]/\1/'`
GPUID=`lspci -nnv | grep -A2 '\[03[08][02]\]:' | grep "Subsystem" | head -n 1 | sed 's/.*:\([[:xdigit:]][[:xdigit:]][[:xdigit:]][[:xdigit:]]\)]/\1/'`

if [ -z "$GPUID" ]; then
    ID=${ROOTID}
else
    ID=${GPUID}
fi

echo "$ID"



