1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-16 21:35:24 +00:00

Actually open the URL

This commit is contained in:
Michael Vetter 2020-05-16 23:41:12 +02:00
parent 083bf34a77
commit 03334664fb
3 changed files with 39 additions and 1 deletions

View File

@ -2449,7 +2449,23 @@ static struct cmd_t command_defs[] =
CMD_EXAMPLES(
"/software valhalla.edda",
"/software xmpp.vanaheimr.edda")
}
},
{ "/urlopen",
parse_args, 1, -1, NULL,
CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_urlopen)
CMD_TAGS(
CMD_TAG_CHAT,
CMD_TAG_GROUPCHAT)
CMD_SYN(
"/urlopen <url>")
CMD_DESC(
"Open the URL")
CMD_ARGS(
{ "<url>", "URL to open."})
CMD_NOEXAMPLES
},
};
static GHashTable *search_index;

View File

@ -8858,3 +8858,23 @@ cmd_slashguard(ProfWin *window, const char *const command, gchar **args)
return TRUE;
}
gboolean
cmd_urlopen(ProfWin *window, const char *const command, gchar **args)
{
if (args[0] == NULL) {
cons_bad_cmd_usage(command);
return TRUE;
}
//TODO: make function. see src/xmpp/avatar.c
GString *cmd = g_string_new("");
g_string_append_printf(cmd, "%s %s > /dev/null 2>&1", "xdg-open", args[0]);
cons_show("Calling: %s", cmd->str);
FILE *stream = popen(cmd->str, "r");
pclose(stream);
g_string_free(cmd, TRUE);
return TRUE;
}

View File

@ -232,4 +232,6 @@ gboolean cmd_correction(ProfWin *window, const char *const command, gchar **args
gboolean cmd_correct(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_slashguard(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_serversoftware(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_urlopen(ProfWin *window, const char *const command, gchar **args);
#endif