Skip to content

Commit

Permalink
fix #31
Browse files Browse the repository at this point in the history
I hope with this I fixed the error.
  • Loading branch information
NachtsternBuild authored Aug 30, 2024
1 parent bb91e49 commit d1c5b43
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Anwendung/header/header_open_url.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* zu erleichtern *
* *
*-------------------------------------------*
* (C) Copyright 2023 Elias Mörz *
* (C) Copyright 2024 Elias Mörz *
*-------------------------------------------*
* *
* Headerpart - open_url *
Expand All @@ -20,18 +20,25 @@

#include <stdlib.h>
#include <gtk/gtk.h>

// function that open the browser
void open_url(const char *url)
{
char url_command[256];

// use the command 'start' and 'xdg-open' to open the website in the browser
#if defined(_WIN32)
sprintf(url_command, "start %s", url);
#elif defined(__linux__)
sprintf(url_command, "xdg-open %s", url);
#endif
// check if the program run via wsl
if (system("grep -q Microsoft /proc/version") == 0)
{
// use the cmd.exe and close it at the end
sprintf(url_command, "cmd.exe /C start %s", url);
}

else
{
// use xdg-open on native linux
sprintf(url_command, "xdg-open %s", url);
}

// run command
system(url_command);
}

0 comments on commit d1c5b43

Please sign in to comment.