From b8a1354117cd02efac4792ce75510fdb15def1b4 Mon Sep 17 00:00:00 2001 From: nicey0 <53410840+nicey0@users.noreply.github.com> Date: Fri, 5 Jun 2020 16:48:17 -0300 Subject: [PATCH] backlight: Just match amdgpu_bl prefix (#2122) Some devices can have "amdgpu_bl1" or "amdgpu_bl2", but the code hardcoded in the value "amdgpu_bl0". This change tests based on the first characters: "amdgpu_bl". --- src/modules/backlight.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/backlight.cpp b/src/modules/backlight.cpp index e8e9f9f8..3b32aa8b 100644 --- a/src/modules/backlight.cpp +++ b/src/modules/backlight.cpp @@ -51,7 +51,8 @@ namespace modules { * The only sensible way is to use the 'brightness' file instead * Ref: https://github.com/Alexays/Waybar/issues/335 */ - auto path_backlight_val = m_path_backlight + "/" + (card == "amdgpu_bl0" ? "brightness" : "actual_brightness"); + std::string brightness_type = ((card.substr(0, 9) == "amdgpu_bl") ? "brightness" : "actual_brightness"); + auto path_backlight_val = m_path_backlight + "/" + brightness_type; m_val.filepath(path_backlight_val); m_max.filepath(m_path_backlight + "/max_brightness");