From 50f7fe4ca5952cb4374e022bc9750b2f926374b4 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 4 Jun 2023 18:29:49 +0000 Subject: [PATCH] Detect if udev rules file is not present and present a warning dialog --- ResourceManager.cpp | 75 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/ResourceManager.cpp b/ResourceManager.cpp index 8a42d205..61240f5e 100644 --- a/ResourceManager.cpp +++ b/ResourceManager.cpp @@ -884,6 +884,29 @@ void ResourceManager::DetectDevicesThreadFunction() \*-------------------------------------------------*/ detection_percent = 0; +#ifdef __linux__ + /*-------------------------------------------------*\ + | Check if the udev rules exist | + \*-------------------------------------------------*/ + bool udev_not_exist = false; + bool udev_multiple = false; + + if(access("/etc/udev/rules.d/60-openrgb.rules", F_OK) != 0) + { + if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) != 0) + { + udev_not_exist = true; + } + } + else + { + if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) == 0) + { + udev_multiple = true; + } + } +#endif + /*-------------------------------------------------*\ | Detect i2c interfaces | \*-------------------------------------------------*/ @@ -1394,27 +1417,59 @@ void ResourceManager::DetectDevicesThreadFunction() LOG_INFO("| Detection completed |"); LOG_INFO("------------------------------------------------------"); +#ifdef __linux__ + /*-------------------------------------------------*\ + | If the udev rules file is not installed, show a | + | dialog | + \*-------------------------------------------------*/ + if(udev_not_exist) + { + const char* message = "

WARNING:

" + "

The OpenRGB udev rules are not installed.

" + "

Most devices will not be available unless running OpenRGB as root.

" + "

If using AppImage, Flatpak, or self-compiled versions of OpenRGB you must install the udev rules manually

" + "

See https://openrgb.org/udev to install the udev rules manually

"; + + LOG_DIALOG("%s", message); + } + + /*-------------------------------------------------*\ + | If multiple udev rules files are installed, show | + | a dialog | + \*-------------------------------------------------*/ + if(udev_multiple) + { + const char* message = "

WARNING:

" + "

Multiple OpenRGB udev rules are installed.

" + "

The udev rules file 60-openrgb.rules is installed in both /etc/udev/rules.d and /usr/lib/udev/rules.d.

" + "

Multiple udev rules files can conflict, it is recommended to remove one of them.

"; + + LOG_DIALOG("%s", message); + } + +#endif + /*-------------------------------------------------*\ | If any i2c interfaces failed to detect due to an | | error condition, show a dialog | \*-------------------------------------------------*/ if(i2c_interface_fail) { - const char* i2c_message = "

WARNING:

" - "

One or more I2C/SMBus interfaces failed to initialize.

" - "

RGB DRAM modules and some motherboards' onboard RGB lighting will not be available without I2C/SMBus.

" + const char* message = "

WARNING:

" + "

One or more I2C/SMBus interfaces failed to initialize.

" + "

RGB DRAM modules and some motherboards' onboard RGB lighting will not be available without I2C/SMBus.

" #ifdef _WIN32 - "

On Windows, this is usually caused by a failure to load the WinRing0 driver. " - "You must run OpenRGB as administrator at least once to allow WinRing0 to set up.

" + "

On Windows, this is usually caused by a failure to load the WinRing0 driver. " + "You must run OpenRGB as administrator at least once to allow WinRing0 to set up.

" #endif #ifdef __linux__ - "

On Linux, this is usually because the i2c-dev module is not loaded. " - "You must load the i2c-dev module along with the correct i2c driver for your motherboard. " - "This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.

" + "

On Linux, this is usually because the i2c-dev module is not loaded. " + "You must load the i2c-dev module along with the correct i2c driver for your motherboard. " + "This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.

" #endif - "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

"; + "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

"; - LOG_DIALOG("%s", i2c_message); + LOG_DIALOG("%s", message); } }