From d914862e31b129de61278754e380310d4e4491c0 Mon Sep 17 00:00:00 2001 From: James Smith Date: Tue, 12 Nov 2024 12:32:39 +0000 Subject: [PATCH] suppress lspci and ldconfig errors unless in debug mode --- lib/mittsu/renderers/generic_lib.rb | 5 ++++- lib/mittsu/renderers/glfw_lib.rb | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/mittsu/renderers/generic_lib.rb b/lib/mittsu/renderers/generic_lib.rb index 205abccb..28bfa9f8 100644 --- a/lib/mittsu/renderers/generic_lib.rb +++ b/lib/mittsu/renderers/generic_lib.rb @@ -1,3 +1,5 @@ +require 'open3' + module Mittsu module GenericLib def discover @@ -32,7 +34,8 @@ def file class << self def kernel_module_in_use - lspci_line = `lspci -nnk | grep -i vga -A3 | grep 'in use'` + lspci_line, stderr, _status = Open3.capture3("lspci -nnk | grep -i vga -A3 | grep 'in use'") + puts stderr if DEBUG /in use:\s*(\S+)/ =~ lspci_line && $1 rescue '' diff --git a/lib/mittsu/renderers/glfw_lib.rb b/lib/mittsu/renderers/glfw_lib.rb index e4159b74..0f6a5f32 100644 --- a/lib/mittsu/renderers/glfw_lib.rb +++ b/lib/mittsu/renderers/glfw_lib.rb @@ -17,7 +17,9 @@ def libgl_paths end def ldconfig - `ldconfig -p | grep 'libglfw3\\?\\.so'`.lines + out, stderr, _status = Open3.capture3("ldconfig -p | grep 'libglfw3\\?\\.so'") + puts stderr if DEBUG + out.lines rescue [] end