mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-09-07 22:31:36 +00:00
Add user-facing error reporting
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
@@ -12,7 +12,9 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -184,6 +186,41 @@ const char *lsi_preload_list()
|
||||
return "/usr/$LIB/libX11.so.6:/usr/$LIB/libstdc++.so.6";
|
||||
}
|
||||
|
||||
void lsi_report_failure(const char *s, ...)
|
||||
{
|
||||
autofree(char) *report = NULL;
|
||||
autofree(char) *emit = NULL;
|
||||
va_list va;
|
||||
va_start(va, s);
|
||||
if (vasprintf(&report, s, va) < 0) {
|
||||
fputs("Critical internal error\n", stderr);
|
||||
return;
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
/* Display not set, just go ahead and stderr it */
|
||||
if (!getenv("DISPLAY")) {
|
||||
goto stderr_log;
|
||||
}
|
||||
|
||||
if (asprintf(&emit,
|
||||
"zenity --title \"%s\" --icon-name='steam' --error --text='%s'",
|
||||
PACKAGE_NAME,
|
||||
report) < 0) {
|
||||
goto stderr_log;
|
||||
}
|
||||
|
||||
if (system(emit) != 0) {
|
||||
fprintf(stderr, "%s: Failed to launch Zenity: %s\n", PACKAGE_NAME, strerror(errno));
|
||||
goto stderr_log;
|
||||
}
|
||||
return;
|
||||
|
||||
stderr_log:
|
||||
fputs(PACKAGE_NAME " failure: \n\t", stderr);
|
||||
fprintf(stderr, "%s\n", report);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
@@ -75,6 +75,12 @@ const char *lsi_preload_list(void);
|
||||
*/
|
||||
bool lsi_system_requires_preload(void);
|
||||
|
||||
/**
|
||||
* Report a failure to the user. In the instance that DISPLAY is set, we'll
|
||||
* attempt to make use of zenity
|
||||
*/
|
||||
void lsi_report_failure(const char *s, ...);
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
|
||||
+3
-1
@@ -76,7 +76,9 @@ int main(int argc, char **argv)
|
||||
/* Go execute steam. */
|
||||
if (execv(exec_command, (char **)n_argv) < 0) {
|
||||
/* TODO: Use Zenity when we have a UI */
|
||||
fprintf(stderr, "Failed to launch Steam: %s [%s]\n", strerror(errno), STEAM_BINARY);
|
||||
lsi_report_failure("Failed to launch Steam: %s [%s]",
|
||||
strerror(errno),
|
||||
STEAM_BINARY);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user