aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2026-02-03 10:26:50 +0000
committerFurkan Sahin <furkan-dev@proton.me>2026-02-03 10:26:50 +0000
commit75daf4d0917f1bc9f1cd40f47cbbb50a4ac15099 (patch)
tree514578e62b2336c95010311d5ae12c80e2ae636b
parent629788a998b00c613dfe1d3756fa02d63d886574 (diff)
sway: change unsupported GPU message to swaynag
This commit shows a swaynag message when an unsupported GPU is detected which must be acknowledged by users. It also adds an environment variable (`SWAY_UNSUPPORTED_GPU`) which may be used instead of the `--unsupported-gpu` argument. The `static` storage class for flag variables in main has also been removed, as this should have no effect on the program. Resolves: #8999
-rw-r--r--include/sway/server.h2
-rw-r--r--sway/main.c24
-rw-r--r--sway/server.c17
3 files changed, 27 insertions, 16 deletions
diff --git a/include/sway/server.h b/include/sway/server.h
index f50d48f0..978f05d0 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -160,7 +160,7 @@ struct sway_debug {
extern struct sway_debug debug;
-extern bool allow_unsupported_gpu;
+extern bool unsupported_gpu_detected;
void sway_terminate(int exit_code);
diff --git a/sway/main.c b/sway/main.c
index 44d07679..e5dc497b 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -224,7 +224,7 @@ static const char usage[] =
"\n";
int main(int argc, char **argv) {
- static bool verbose = false, debug = false, validate = false;
+ bool verbose = false, debug = false, validate = false, allow_unsupported_gpu = false;
char *config_path = NULL;
@@ -286,6 +286,12 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ char *unsupported_gpu_env = getenv("SWAY_UNSUPPORTED_GPU");
+ // we let the flag override the environment variable
+ if (!allow_unsupported_gpu && unsupported_gpu_env) {
+ allow_unsupported_gpu = parse_boolean(unsupported_gpu_env, false);
+ }
+
// As the 'callback' function for wlr_log is equivalent to that for
// sway, we do not need to override it.
if (debug) {
@@ -373,6 +379,18 @@ int main(int argc, char **argv) {
swaynag_show(&config->swaynag_config_errors);
}
+ struct swaynag_instance nag_gpu = (struct swaynag_instance){
+ .args = "--type error "
+ "--message 'Proprietary GPU drivers are not supported by sway. Do not report issues.' ",
+ .detailed = false,
+ };
+
+ if (unsupported_gpu_detected && !allow_unsupported_gpu) {
+ if (!swaynag_spawn(config->swaynag_command, &nag_gpu)) {
+ sway_log(SWAY_ERROR, "Unable to start swaynag");
+ }
+ }
+
server_run(&server);
shutdown:
@@ -385,6 +403,10 @@ shutdown:
free(config_path);
free_config(config);
+ if (nag_gpu.client != NULL) {
+ wl_client_destroy(nag_gpu.client);
+ }
+
pango_cairo_font_map_set_default(NULL);
return exit_value;
diff --git a/sway/server.c b/sway/server.c
index 6003f455..aef0d0b0 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -78,7 +78,7 @@
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
#define SWAY_PRESENTATION_VERSION 2
-bool allow_unsupported_gpu = false;
+bool unsupported_gpu_detected = false;
#if WLR_HAS_DRM_BACKEND
static void handle_drm_lease_request(struct wl_listener *listener, void *data) {
@@ -161,27 +161,16 @@ static void detect_proprietary(struct wlr_backend *backend, void *data) {
return;
}
- bool is_unsupported = false;
if (strcmp(version->name, "nvidia-drm") == 0) {
- is_unsupported = true;
+ unsupported_gpu_detected = true;
sway_log(SWAY_ERROR, "!!! Proprietary Nvidia drivers are in use !!!");
- if (!allow_unsupported_gpu) {
- sway_log(SWAY_ERROR, "Use Nouveau instead");
- }
}
if (strcmp(version->name, "evdi") == 0) {
- is_unsupported = true;
+ unsupported_gpu_detected = true;
sway_log(SWAY_ERROR, "!!! Proprietary DisplayLink drivers are in use !!!");
}
- if (!allow_unsupported_gpu && is_unsupported) {
- sway_log(SWAY_ERROR,
- "Proprietary drivers are NOT supported. To launch sway anyway, "
- "launch with --unsupported-gpu and DO NOT report issues.");
- exit(EXIT_FAILURE);
- }
-
drmFreeVersion(version);
}