diff options
author | Daniel Santos <dacs.git@brilhante.top> | 2023-03-24 14:56:35 +0000 |
---|---|---|
committer | Daniel Santos <dan.git@brilhante.top> | 2023-07-01 10:08:20 +0100 |
commit | 35351387a197e55f5389545efe3941b58ca94ffd (patch) | |
tree | 87bba0f195ad83c9f895f91f1119cd099b954c71 /src/command | |
parent | c402f8d9d2b3f94bbc20ba9c0c43f6df3b7ca885 (diff) | |
download | profani-tty-35351387a197e55f5389545efe3941b58ca94ffd.tar.gz |
/executable async on|off
* rename call_external() to call_external_async(). * add call_external_fork(). This function makes all executable calls to be forked and synchronous. So that running profanity inside a TTY, we can set all executables to be TTY programs (fbi, mpv, w3m, emacs eww, etc.), making possible to open urls or see images inside the TTY. * add '/executable async' command. * make call_external() use either call_external_async() or call_external_fork(), according to the '/executable async' configuration. Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/cmd_ac.c | 6 | ||||
-rw-r--r-- | src/command/cmd_defs.c | 12 | ||||
-rw-r--r-- | src/command/cmd_funcs.c | 13 | ||||
-rw-r--r-- | src/command/cmd_funcs.h | 1 |
4 files changed, 23 insertions, 9 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index d182e4db..527281a7 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -1116,11 +1116,7 @@ cmd_ac_init(void) autocomplete_add(executable_ac, "urlopen"); autocomplete_add(executable_ac, "urlsave"); autocomplete_add(executable_ac, "editor"); - autocomplete_add(executable_ac, "vcard_photo"); - - executable_param_ac = autocomplete_new(); - autocomplete_add(executable_param_ac, "set"); - autocomplete_add(executable_param_ac, "default"); + autocomplete_add(executable_ac, "async"); intype_ac = autocomplete_new(); autocomplete_add(intype_ac, "console"); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 9bc8b6f2..1aee5fb8 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -2531,7 +2531,8 @@ static const struct cmd_t command_defs[] = { { "urlopen", cmd_executable_urlopen }, { "urlsave", cmd_executable_urlsave }, { "editor", cmd_executable_editor }, - { "vcard_photo", cmd_executable_vcard_photo }) + { "vcard_photo", cmd_executable_vcard_photo }, + { "async", cmd_executable_async }) CMD_TAGS( CMD_TAG_DISCOVERY) CMD_SYN( @@ -2544,7 +2545,8 @@ static const struct cmd_t command_defs[] = { "/executable editor set <cmdtemplate>", "/executable editor default", "/executable vcard_photo set <cmdtemplate>", - "/executable vcard_photo default") + "/executable vcard_photo default", + "/executable async on|off") CMD_DESC( "Configure executable that should be called upon a certain command.") CMD_ARGS( @@ -2557,7 +2559,8 @@ static const struct cmd_t command_defs[] = { { "editor set", "Set editor to be used with /editor. Needs a terminal editor or a script to run a graphical editor." }, { "editor default", "Restore to default settings." }, { "vcard_photo set", "Set executable that is run by /vcard photo open. Takes a command template that replaces %p with the path" }, - { "vcard_photo default", "Restore to default settings." }) + { "vcard_photo default", "Restore to default settings." }, + { "async on|off", "Enable or disable async call of executables. Disable async if all executables run inside the TTY." }) CMD_EXAMPLES( "/executable avatar xdg-open", "/executable urlopen set \"xdg-open %u\"", @@ -2566,8 +2569,9 @@ static const struct cmd_t command_defs[] = { "/executable urlsave set \"wget %u -O %p\"", "/executable urlsave set \"curl %u -o %p\"", "/executable urlsave default", + "/executable editor set \"emacsclient -t\"", "/executable vcard_photo set \"feh %p\"", - "/executable editor set \"emacsclient -t\"") + "/executable async off") }, { CMD_PREAMBLE("/url", diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index ffa8a3d2..f5535ad9 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -10864,3 +10864,16 @@ cmd_vcard_save(ProfWin* window, const char* const command, gchar** args) cons_show("User vCard uploaded"); return TRUE; } + +gboolean +cmd_executable_async(ProfWin* window, const char* const command, gchar** args) +{ + if (args[1] == NULL) { + cons_bad_cmd_usage(command); + return TRUE; + } + + _cmd_set_boolean_preference(args[1], command, "Run executables asynchronously", PREF_EXECUTABLE_ASYNC); + + return TRUE; +} diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 400261d3..53fa7f31 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -267,5 +267,6 @@ gboolean cmd_vcard_photo(ProfWin* window, const char* const command, gchar** arg gboolean cmd_vcard_refresh(ProfWin* window, const char* const command, gchar** args); gboolean cmd_vcard_set(ProfWin* window, const char* const command, gchar** args); gboolean cmd_vcard_save(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_executable_async(ProfWin* window, const char* const command, gchar** args); #endif |