Created
April 29, 2024 03:24
-
-
Save gr33n7007h/1b1c7cb848a6bc7dbe90178cf1163bc2 to your computer and use it in GitHub Desktop.
for zayd on #ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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