Skip to content

Commit

Permalink
Open authorization link in graphical browser
Browse files Browse the repository at this point in the history
We can not launch terminal browser because it will interfere with
getchar() waiting approach.
  • Loading branch information
arkq committed Jun 6, 2022
1 parent 1f8e6fb commit 5afbd78
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const char *cmusfm_socket_file = NULL;
/* Global configuration structure */
struct cmusfm_config config;

/* Access global environment variables */
extern char **environ;

/* Parse status arguments which we've get from the cmus and return track info
* structure. Upon error NULL is returned and errno is set appropriately. */
Expand Down Expand Up @@ -121,15 +123,15 @@ static int user_authorization(const char *url) {
char *cmd = "open";
char * const argv[] = { cmd, (char *)url, NULL };
#else
char *cmd = "xdg-open";
char *cmd = "x-www-browser";
char * const argv[] = { cmd, (char *)url, NULL };
#endif

pid_t pid;
int status;

/* spawn "open" command and forget */
if (posix_spawnp(&pid, cmd, NULL, NULL, argv, NULL) == 0)
if (posix_spawnp(&pid, cmd, NULL, NULL, argv, environ) == 0)
waitpid(pid, &status, WNOHANG);

getchar();
Expand Down

0 comments on commit 5afbd78

Please sign in to comment.