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
This commit is contained in:
Calvin Lee 2026-02-03 10:26:50 +00:00 committed by Kenny Levinsen
parent b081eba05d
commit 992d201512
3 changed files with 27 additions and 16 deletions

View file

@ -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;