Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h
Created April 29, 2024 03:24
Show Gist options
  • Save gr33n7007h/1b1c7cb848a6bc7dbe90178cf1163bc2 to your computer and use it in GitHub Desktop.
Save gr33n7007h/1b1c7cb848a6bc7dbe90178cf1163bc2 to your computer and use it in GitHub Desktop.
for zayd on #ruby
# parse lspci output
require 'shellwords'
def parse_lspci_output
IO.popen('lspci -m') do |io|
io.readlines.filter_map do |line|
if line.match?(/3D|VGA|Display/)
pci_vendor, pci_device = line.shellsplit[2..4]
"#{pci_vendor} #{pci_device}"
end
end
end
rescue Errno::ENOENT => e
# warn e.message or return [] ???
[]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment