mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-20 18:52:43 +00:00
- Clean up the availability detection of kdialog
and gxmessage
in POSIX sources.
* Both `kdialog` and `gxmessage` are not core components of the KDE or GNOME desktop environments. * The environment variable `GNOME_DESKTOP_SESSION_ID` has been deprecated for nearly a decade. * Systems like Steam Deck are shipping with stripped down DEs where these environment variables were set, but without the associated binaries.
This commit is contained in:
parent
3f9a2a2103
commit
70b6aa848f
2 changed files with 14 additions and 17 deletions
|
@ -15,6 +15,8 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
int I_FileAvailable(const char* filename);
|
||||
|
||||
|
||||
static const char crash_switch[] = "--cc-handle-crash";
|
||||
|
||||
|
@ -363,12 +365,11 @@ static void crash_handler(const char *logfile)
|
|||
|
||||
if(logfile)
|
||||
{
|
||||
const char *str;
|
||||
char buf[512];
|
||||
|
||||
if((str=getenv("KDE_FULL_SESSION")) && strcmp(str, "true") == 0)
|
||||
if(I_FileAvailable("kdialog"))
|
||||
snprintf(buf, sizeof(buf), "kdialog --title \"Very Fatal Error\" --textbox \"%s\" 800 600", logfile);
|
||||
else if((str=getenv("GNOME_DESKTOP_SESSION_ID")) && str[0] != '\0')
|
||||
else if(I_FileAvailable("gxmessage"))
|
||||
snprintf(buf, sizeof(buf), "gxmessage -buttons \"Okay:0\" -geometry 800x600 -title \"Very Fatal Error\" -center -file \"%s\"", logfile);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "xmessage -buttons \"Okay:0\" -center -file \"%s\"", logfile);
|
||||
|
|
|
@ -85,22 +85,18 @@ void I_SetIWADInfo()
|
|||
{
|
||||
}
|
||||
|
||||
static bool I_KDialogAvailable()
|
||||
extern "C" int I_FileAvailable(const char* filename)
|
||||
{
|
||||
// Is KDE running?
|
||||
const char* str = getenv("KDE_FULL_SESSION");
|
||||
if (str && strcmp(str, "true") == 0)
|
||||
FString cmd = "which {0} >/dev/null 2>&1";
|
||||
cmd.Substitute("{0}", filename);
|
||||
|
||||
if (FILE* f = popen(cmd.GetChars(), "r"))
|
||||
{
|
||||
// Is kdialog available?
|
||||
FILE* f = popen("which kdialog >/dev/null 2>&1", "r");
|
||||
if (f != NULL)
|
||||
{
|
||||
int status = pclose(f);
|
||||
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
||||
}
|
||||
int status = pclose(f);
|
||||
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -117,7 +113,7 @@ void Unix_I_FatalError(const char* errortext)
|
|||
// Close window or exit fullscreen and release mouse capture
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
if(I_KDialogAvailable())
|
||||
if(I_FileAvailable("kdialog"))
|
||||
{
|
||||
FString cmd;
|
||||
cmd << "kdialog --title \"" GAMENAME " " << GetVersionString()
|
||||
|
@ -311,7 +307,7 @@ int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&
|
|||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
if(I_KDialogAvailable())
|
||||
if(I_FileAvailable("kdialog"))
|
||||
{
|
||||
FString cmd("kdialog --title \"" GAMENAME " ");
|
||||
cmd << GetVersionString() << ": Select an IWAD to use\""
|
||||
|
|
Loading…
Reference in a new issue