From 4ef60e7c094e3d27a068d0ae94d40dbefd38cfac Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 2 Sep 2015 11:46:21 -0400 Subject: [PATCH] Add check for nvidia module and warn user --- sway/main.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sway/main.c b/sway/main.c index 9c7f21b39..20738307b 100644 --- a/sway/main.c +++ b/sway/main.c @@ -8,6 +8,7 @@ #include "layout.h" #include "config.h" #include "log.h" +#include "readline.h" #include "handlers.h" #include "ipc.h" #include "sway.h" @@ -31,6 +32,22 @@ static void wlc_log_handler(enum wlc_log_type type, const char *str) { } } +void detect_nvidia() { + FILE *f = fopen("/proc/modules", "r"); + if (!f) { + return; + } + while (!feof(f)) { + char *line = read_line(f); + if (strstr(line, "nvidia")) { + fprintf(stderr, "\x1B[1;31mWarning: Proprietary nvidia drivers do NOT support Wayland. Use nouveau.\x1B[0m\n"); + free(line); + return; + } + free(line); + } +} + int main(int argc, char **argv) { static int verbose = 0, debug = 0, validate = 0; @@ -51,6 +68,8 @@ int main(int argc, char **argv) { wlc_log_set_handler(wlc_log_handler); + detect_nvidia(); + /* Changing code earlier than this point requires detailed review */ if (!wlc_init(&interface, argc, argv)) { return 1;