Detect if udev rules file is not present and present a warning dialog

This commit is contained in:
Adam Honse
2023-06-04 18:29:49 +00:00
parent ccb8997764
commit 50f7fe4ca5

View File

@@ -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 = "<h2>WARNING:</h2>"
"<p>The OpenRGB udev rules are not installed.</p>"
"<p>Most devices will not be available unless running OpenRGB as root.</p>"
"<p>If using AppImage, Flatpak, or self-compiled versions of OpenRGB you must install the udev rules manually</p>"
"<p>See <a href='https://openrgb.org/udev'>https://openrgb.org/udev</a> to install the udev rules manually</p>";
LOG_DIALOG("%s", message);
}
/*-------------------------------------------------*\
| If multiple udev rules files are installed, show |
| a dialog |
\*-------------------------------------------------*/
if(udev_multiple)
{
const char* message = "<h2>WARNING:</h2>"
"<p>Multiple OpenRGB udev rules are installed.</p>"
"<p>The udev rules file 60-openrgb.rules is installed in both /etc/udev/rules.d and /usr/lib/udev/rules.d.</p>"
"<p>Multiple udev rules files can conflict, it is recommended to remove one of them.</p>";
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 = "<h2>WARNING:</h2>"
"<p>One or more I2C/SMBus interfaces failed to initialize.</p>"
"<p>RGB DRAM modules and some motherboards' onboard RGB lighting will not be available without I2C/SMBus.</p>"
const char* message = "<h2>WARNING:</h2>"
"<p>One or more I2C/SMBus interfaces failed to initialize.</p>"
"<p>RGB DRAM modules and some motherboards' onboard RGB lighting will not be available without I2C/SMBus.</p>"
#ifdef _WIN32
"<p>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.</p>"
"<p>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.</p>"
#endif
#ifdef __linux__
"<p>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.</p>"
"<p>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.</p>"
#endif
"<p>See <a href='https://help.openrgb.org/'>help.openrgb.org</a> for additional troubleshooting steps if you keep seeing this message.<br></p>";
"<p>See <a href='https://help.openrgb.org/'>help.openrgb.org</a> for additional troubleshooting steps if you keep seeing this message.<br></p>";
LOG_DIALOG("%s", i2c_message);
LOG_DIALOG("%s", message);
}
}