diff --git a/CHANGELOG.md b/CHANGELOG.md index d3936c370cb46d06259a70179116ba438e576966..25de4d383a3bcfa4d43454266de522d20be1a0a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ If a change only affects particular applications, they are listed in parentheses - misc: Make scdoc a native dependency to enable cross-compilation (!30, thanks @uninsane) - fix: Use usleep to release CPU when possible (!31, thanks @uninsane) - feat(buffyboard): Add a buffyboard.service systemd service (!34, @uninsane) +- fix(unl0kr): Select an available DRM device instead of a hard-coded one (!35, thanks @Sorcus) ## 3.2.0 (2024-06-03) diff --git a/unl0kr/main.c b/unl0kr/main.c index 02da2f33bd4550cfed7669ba06ce378e7a28869c..42d6d6e29cd3fe7f4478b7aaff37d2c2fa30c0af 100644 --- a/unl0kr/main.c +++ b/unl0kr/main.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <sys/reboot.h> +#include <sys/stat.h> #include <sys/time.h> @@ -420,7 +421,23 @@ int main(int argc, char *argv[]) { case UL_BACKENDS_BACKEND_DRM: bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using DRM backend"); disp = lv_linux_drm_create(); - lv_linux_drm_set_file(disp, "/dev/dri/card0", -1); + + char *format_string = "/dev/dri/card%d"; + char drm_path[16] = {0}; + struct stat buffer; + + for (size_t i = 0; i < 9; i++) { + sprintf(drm_path, format_string, i); + + if (stat(drm_path, &buffer) != 0) { + continue; + } + + lv_linux_drm_set_file(disp, drm_path, -1); + + break; + } + break; #endif /* LV_USE_LINUX_DRM */ default: