about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_defs.c8
-rw-r--r--src/command/cmd_funcs.c33
-rw-r--r--src/config/preferences.c2
3 files changed, 24 insertions, 19 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index c6e886a5..ceb84d05 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -2437,7 +2437,7 @@ static const struct cmd_t command_defs[] = {
               { "set <path>", "Set avatar to the image at <path>." },
               { "disable", "Disable avatar publishing; your avatar will not display to others." },
               { "get <barejid>", "Download the avatar. barejid is the JID to download avatar from." },
-              { "open <barejid>", "Download avatar and open it with command." })
+              { "open <barejid>", "Download avatar and open it with command. See /executable." })
       CMD_EXAMPLES(
               "/avatar set ~/images/avatar.png",
               "/avatar disable",
@@ -2534,7 +2534,8 @@ static const struct cmd_t command_defs[] = {
       CMD_TAGS(
               CMD_TAG_DISCOVERY)
       CMD_SYN(
-              "/executable avatar <cmd>",
+              "/executable avatar set <cmdtemplate>",
+              "/executable avatar default",
               "/executable urlopen set <cmdtemplate>",
               "/executable urlopen default",
               "/executable urlsave set <cmdtemplate>",
@@ -2545,7 +2546,8 @@ static const struct cmd_t command_defs[] = {
       CMD_DESC(
               "Configure executable that should be called upon a certain command.")
       CMD_ARGS(
-              { "avatar", "Set executable that is run by /avatar open. Use your favorite image viewer." },
+              { "avatar set", "Set executable that is run by /avatar open. Use your favorite image viewer." },
+              { "avatar default", "Restore to default settings." },
               { "urlopen set", "Set executable that is run by /url open. Takes a command template that replaces %u and %p with the URL and path respectively." },
               { "urlopen default", "Restore to default settings." },
               { "urlsave set", "Set executable that is run by /url save. Takes a command template that replaces %u and %p with the URL and path respectively." },
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index b0e287f2..e18498c6 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -9617,15 +9617,7 @@ out:
 }
 
 gboolean
-cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args)
-{
-    prefs_set_string(PREF_AVATAR_CMD, args[1]);
-    cons_show("`avatar` command set to invoke '%s'", args[1]);
-    return TRUE;
-}
-
-gboolean
-cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args)
+_cmd_executable_template(const preference_t setting, const char* command, gchar** args)
 {
     guint num_args = g_strv_length(args);
     if (num_args < 2) {
@@ -9635,14 +9627,14 @@ cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args)
 
     if (g_strcmp0(args[1], "set") == 0 && num_args >= 3) {
         gchar* str = g_strjoinv(" ", &args[2]);
-        prefs_set_string(PREF_URL_OPEN_CMD, str);
-        cons_show("`url open` command set to invoke '%s'", str);
+        prefs_set_string(setting, str);
+        cons_show("`%s` command set to invoke '%s'", command, str);
         g_free(str);
 
     } else if (g_strcmp0(args[1], "default") == 0) {
-        prefs_set_string(PREF_URL_OPEN_CMD, NULL);
-        gchar* def = prefs_get_string(PREF_URL_OPEN_CMD);
-        cons_show("`url open` command set to invoke %s (default)", def);
+        prefs_set_string(setting, NULL);
+        gchar* def = prefs_get_string(setting);
+        cons_show("`%s` command set to invoke %s (default)", command, def);
         g_free(def);
     } else {
         cons_bad_cmd_usage(command);
@@ -9652,9 +9644,20 @@ cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args)
 }
 
 gboolean
-cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args)
+cmd_executable_avatar(ProfWin* window, const char* const command, gchar** args)
 {
+    return _cmd_executable_template(PREF_AVATAR_CMD, args[0], args);
+}
 
+gboolean
+cmd_executable_urlopen(ProfWin* window, const char* const command, gchar** args)
+{
+    return _cmd_executable_template(PREF_URL_OPEN_CMD, args[0], args);
+}
+
+gboolean
+cmd_executable_urlsave(ProfWin* window, const char* const command, gchar** args)
+{
     guint num_args = g_strv_length(args);
     if (num_args < 2) {
         cons_bad_cmd_usage(command);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 2d975e39..f1b4154e 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -2314,7 +2314,7 @@ _get_default_string(preference_t pref)
     case PREF_COLOR_NICK:
         return "false";
     case PREF_AVATAR_CMD:
-        return "xdg-open";
+        return "xdg-open %p";
     case PREF_URL_OPEN_CMD:
         return "xdg-open %u";
     case PREF_VCARD_PHOTO_CMD: